next.js: Next.js 13.4.13 returns 500 while running on iisnode, 13.4.12 runs without errors

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
	Platform: win32
	Arch: x64
	Version: Windows Server 2019 Standard
Binaries:
	Node: 20.2.0
	npm: N/A
	Yarn: N/A
	pnpm: 8.6.0
Relevant Packages:
	next: 13.4.13
	eslint-config-next: 13.4.13
	react: 18.2.0
	react-dom: 18.2.0
	typescript: 5.1.6
Next.js Config:
	output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

.

To Reproduce

Website launch

Describe the Bug

After updating to 13.4.13, a 500 error is thrown immediately. No further details. Neither the Windows error log nor the iisnode itself provide more detailed information. Jumping back to 13.4.12 works again without errors.

Expected Behavior

Website launch or at least more accurate error

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

custom server.js

NEXT-1566

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 27
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Same here, 13.4.13, log form Docker:

23-08-09T13:34:19.013867627Z - error Failed to handle request for / 2023-08-09T13:34:19.014667009Z TypeError: fetch failed 2023-08-09T13:34:19.014721093Z at Object.fetch (node:internal/deps/undici/undici:11576:11) 2023-08-09T13:34:19.014731171Z at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 2023-08-09T13:34:19.014740568Z at async invokeRequest (/app/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:21:12) 2023-08-09T13:34:19.014749716Z at async requestHandler (/app/node_modules/next/dist/server/lib/start-server.js:336:33) 2023-08-09T13:34:19.014759021Z at async Server.<anonymous> (/app/node_modules/next/dist/server/lib/start-server.js:152:13) { 2023-08-09T13:34:19.014768773Z cause: Error: connect ECONNREFUSED 127.0.0.1:39647 2023-08-09T13:34:19.014777755Z at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) { 2023-08-09T13:34:19.014786567Z errno: -111, 2023-08-09T13:34:19.014795100Z code: ‘ECONNREFUSED’, 2023-08-09T13:34:19.014803714Z syscall: ‘connect’, 2023-08-09T13:34:19.014812252Z address: ‘127.0.0.1’, 2023-08-09T13:34:19.014820680Z port: 39647 2023-08-09T13:34:19.014829467Z } 2023-08-09T13:34:19.014837998Z } 2023-08-09T13:34:19.050695820Z - error Failed to handle request for /favicon.ico 2023-08-09T13:34:19.051528307Z TypeError: fetch failed 2023-08-09T13:34:19.051585674Z at Object.fetch (node:internal/deps/undici/undici:11576:11) 2023-08-09T13:34:19.051595357Z at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 2023-08-09T13:34:19.051604736Z at async invokeRequest (/app/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:21:12) 2023-08-09T13:34:19.051613845Z at async requestHandler (/app/node_modules/next/dist/server/lib/start-server.js:336:33) 2023-08-09T13:34:19.051622810Z at async Server.<anonymous> (/app/node_modules/next/dist/server/lib/start-server.js:152:13) { 2023-08-09T13:34:19.051655036Z cause: Error: connect ECONNREFUSED 127.0.0.1:39647 2023-08-09T13:34:19.051664645Z at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) { 2023-08-09T13:34:19.051673823Z errno: -111, 2023-08-09T13:34:19.051682471Z code: ‘ECONNREFUSED’, 2023-08-09T13:34:19.051691127Z syscall: ‘connect’, 2023-08-09T13:34:19.051699949Z address: ‘127.0.0.1’, 2023-08-09T13:34:19.051708714Z port: 39647 2023-08-09T13:34:19.051717318Z } 2023-08-09T13:34:19.051725836Z }

In my case, i’m not using iisnode. But Next.js 13.4.13 returns 500 is same. So I’ll leave the reproduction procedure here.

Steps to reproduce

Prepare

Use with-docker example and set specific next version (13.4.13)

$ pnpm create next-app --example with-docker nextjs-docker
$ cd nextjs-docker
$ pnpm add next@13.4.13 # set specific version
$ pnpm exec next info

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.6.0: Wed Jul  5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020
    Binaries:
      Node: 18.16.1
      npm: 9.8.1
      Yarn: 1.22.19
      pnpm: 8.6.4
    Relevant Packages:
      next: 13.4.13
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A
    Next.js Config:
      output: standalone

Running dev server

it works

$ pnpm run dev
$ open http://localhost:3000 # it works

Running standalone server

it works

$ pnpm run build
$ node .next/standalone/server.js
$ open http://localhost:3000 # it works

Running standalone server with Docker

it doesn’t work

$ docker build -t nextjs-docker .
$ docker run -p 3000:3000 nextjs-docker
$ open http://localhost:3000 # it doesn't work

$ curl -v http://localhost:3000
*   Trying 127.0.0.1:3000...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.1.2
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< Date: Sat, 19 Aug 2023 06:25:30 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
Internal Server Error%      

docker run -p 3000:3000 nextjs-docker log:

- ready started server on f8a7c152c094:3000, url: http://f8a7c152c094:3000
Listening on port 3000 url: http://f8a7c152c094:3000
- error Failed to handle request for /
TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11576:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async invokeRequest (/app/node_modules/.pnpm/next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:21:12)
    at async requestHandler (/app/node_modules/.pnpm/next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/lib/start-server.js:336:33)
    at async Server.<anonymous> (/app/node_modules/.pnpm/next@13.4.13_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/lib/start-server.js:152:13) {
  cause: Error: connect ECONNREFUSED 127.0.0.1:37745
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 37745
  }
}

Canary: Running standalone server with Docker

it works

$ pnpm add next@canary
$ pnpm exec next info

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.6.0: Wed Jul  5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020
    Binaries:
      Node: 18.16.1
      npm: 9.8.1
      Yarn: 1.22.19
      pnpm: 8.6.4
    Relevant Packages:
      next: 13.4.19-canary.0
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A
    Next.js Config:
      output: standalone

$ docker build -t nextjs-docker .
$ docker run -p 3000:3000 nextjs-docker
$ open http://localhost:3000 # it works

I can confirm that version 13.4.16 did not fix the issue. 13.4.12 is the last version that runs without errors. @timneutkens are you aware of the problem, is something happening here? 😃

Seeing a similar issue. We also use a custom server.js.

14:58:11 node:internal/process/promises:288
14:58:11             triggerUncaughtException(err, true /* fromPromise */);
14:58:11             ^
14:58:11 
14:58:11 Error: Call retries were exceeded
14:58:11     at ChildProcessWorker.initialize (/home/jenkins/agent/workspace/xx/node_modules/next/dist/compiled/jest-worker/index.js:1:11661)
14:58:11     at ChildProcessWorker._onExit (/home/jenkins/agent/workspace/xx/node_modules/next/dist/compiled/jest-worker/index.js:1:12599)
14:58:11     at ChildProcess.emit (node:events:513:28)
14:58:11     at ChildProcess._handle.onexit (node:internal/child_process:291:12) {
14:58:11   type: 'WorkerError'
14:58:11 }

All is good when dropping to 13.4.12.

@ztanner Thanks for letting me know that! The problem I reported has been fixed in the latest version (13.4.19). 🎉

18-alpine here v13.4.16 did not resolve issue

v13.4.16 did not resolve the issue here. Using Docker, Alpine distribution.