Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes error code from node errors #291

Closed
cspotcode opened this issue Jul 19, 2021 · 2 comments · Fixed by cspotcode/node-source-map-support#3 · May be fixed by #292
Closed

Removes error code from node errors #291

cspotcode opened this issue Jul 19, 2021 · 2 comments · Fixed by cspotcode/node-source-map-support#3 · May be fixed by #292

Comments

@cspotcode
Copy link

cspotcode commented Jul 19, 2021

Related to TypeStrong/ts-node#1403

On the new node 16.5, important information is being omitted from uncaught error output.

❯ node --version
v16.5.0
❯ npm why source-map-support
source-map-support@0.5.19

From vanilla node:

❯ node -e 'import("https://example.com")' 
node:internal/errors:463
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. Received protocol 'https:'
    at new NodeError (node:internal/errors:370:5)
    at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:839:11)
    at Loader.resolve (node:internal/modules/esm/loader:89:40)
    at Loader.getModuleJob (node:internal/modules/esm/loader:242:28)
    at Loader.import (node:internal/modules/esm/loader:177:28)
    at importModuleDynamically (node:internal/process/execution:87:29)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

With source-map-support the output is modified in ways that I think should be considered a bug.

For example, [ERR_UNSUPPORTED_ESM_URL_SCHEME] is omitted:

❯ node --require source-map-support/register -e 'import("https://example.com")'
Error: Only file and data URLs are supported by the default ESM loader. Received protocol 'https:'
    at new NodeError (node:internal/errors:370:5)
    at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:839:11)
    at Loader.resolve (node:internal/modules/esm/loader:89:40)
    at Loader.getModuleJob (node:internal/modules/esm/loader:242:28)
    at Loader.import (node:internal/modules/esm/loader:177:28)
    at importModuleDynamically (node:internal/process/execution:87:29)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)

This is not the same as #263, although anyone who attempts this reproduction will notice the lack of colored output.

@cspotcode
Copy link
Author

I think source-map-support's prepareStackTrace implementation may need to be updated to match node's implementation:
https://github.com/nodejs/node/blob/3cbaabc4622df1b4009b9d026a1a970bdbae6e89/lib/internal/errors.js#L90-L133

@cspotcode
Copy link
Author

Here is the node PR which changed its behavior:
nodejs/node#39182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant