Skip to content

TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type string ('SIGINT') #173

@bennycode

Description

@bennycode

Checklist

  • I have looked into the Readme and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

When hitting Ctrl + C while the application is running, it won't stop and crash instead with the following error:

(/home/bennycode/dev/bennycode/benny-carbon-hub/node_modules/next/dist/server/lib/start-server.js:208:29)
[0]     at process.emit (node:events:526:35) {
[0]   code: 'ERR_INVALID_ARG_TYPE'
[0] }
[0]  X uncaughtException: TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type string ('SIGINT')

Reproduction

  1. npm run dev
  2. Hit "Ctrl + C" on Windows to stop the processs

Additional context

The problem exists because the samples use the outdated Next.js v13 which has a bug in it's cleanup code:

                const cleanup = (code)=>{
                    debug("start-server process cleanup");
                    server.close();
                    process.exit(code ?? 0);
                };
                process.on("SIGINT", cleanup);

The start-server.js file in Next v13 sends the string SIGINT to process.exit which is not allowed as it is not a number.

It is fixed in Next v14.0.1 -> https://github.com/vercel/next.js/blob/v14.0.1/packages/next/src/server/lib/start-server.ts#L273

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions