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

error message regression in node 13 vs 12 #31284

Open
ljharb opened this issue Jan 9, 2020 · 10 comments
Open

error message regression in node 13 vs 12 #31284

ljharb opened this issue Jan 9, 2020 · 10 comments
Labels

Comments

@ljharb
Copy link
Member

@ljharb ljharb commented Jan 9, 2020

With this file, tmp, with +x permissions:

#!/usr/bin/env node

'syntax error

node tmp in node 12 / nvm run 12 tmp begets:

$PWD/tmp:3
'syntax error
^^^^^^^^^^^^^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:895:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11

node tmp in node 13.6 / nvm run 13 tmp begets:

$PWD/tmp:1
#!/usr/bin/env node
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (internal/modules/cjs/loader.js:1060:16)
    at Module._compile (internal/modules/cjs/loader.js:1108:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
    at Module.load (internal/modules/cjs/loader.js:993:32)
    at Function.Module._load (internal/modules/cjs/loader.js:892:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

The error message in node 13 was highly confusing and I had no idea where the syntax error was in the actual file (which was obviously much larger) until I thought to test it in node 12.

@ljharb

This comment has been minimized.

Copy link
Member Author

@ljharb ljharb commented Jan 9, 2020

cc @nodejs/modules-active-members in case it has to do with loader changes, and in case this can be fixed before it's backported to node 12.

@jkrems

This comment has been minimized.

Copy link
Contributor

@jkrems jkrems commented Jan 9, 2020

Does this happen without the shebang as well or is this specific to it?

Previously reported issue: nodejs/modules#464

@devsnek devsnek added the V8 Engine label Jan 9, 2020
@devsnek

This comment has been minimized.

Copy link
Member

@devsnek devsnek commented Jan 9, 2020

This bug can reproduced in pure V8. I'd suggest reporting it upstream.

@GeoffreyBooth

This comment has been minimized.

Copy link
Member

@GeoffreyBooth GeoffreyBooth commented Jan 9, 2020

This bug can reproduced in pure V8. I'd suggest reporting it upstream.

Out of curiosity, how do you test that?

@ljharb

This comment has been minimized.

Copy link
Member Author

@ljharb ljharb commented Jan 9, 2020

I'll file it upstream (testing details would help), but upgrading v8 in node 12 seems like a problem since it will break the usefulness of error messages in an LTS node, so upstream or not, it seems like something we'd have to address :-/

@jkrems

This comment has been minimized.

Copy link
Contributor

@jkrems jkrems commented Jan 9, 2020

> vm.createScript('#!/usr/bin/env node\n\n\'syntax error').runInThisContext()
evalmachine.<anonymous>:1
#!/usr/bin/env node
^

Uncaught SyntaxError: Invalid or unexpected token
> vm.createScript('#!/usr/bin/env node\n\n42-').runInThisContext()
evalmachine.<anonymous>:3
42-


Uncaught SyntaxError: Unexpected end of input

Looks like it's specific to certain kinds of SyntaxError only?

@devsnek

This comment has been minimized.

Copy link
Member

@devsnek devsnek commented Jan 9, 2020

@jkrems The issues are actually unrelated. Note where the arrow is pointing @SMotaal's issue.

@GeoffreyBooth I have a local checkout and build of V8, which includes a command-line debugging tool called d8. https://v8.dev/docs/d8

@ljharb

This comment has been minimized.

Copy link
Member Author

@ljharb ljharb commented Jan 9, 2020

Filed https://bugs.chromium.org/p/v8/issues/detail?id=10110, it'd be great if folks helped flesh it out.

@ljharb

This comment has been minimized.

Copy link
Member Author

@ljharb ljharb commented Jan 9, 2020

@devsnek given that the node 13 error comes from at wrapSafe (internal/modules/cjs/loader.js:1060:16), doesn't that imply it's an issue in node's CJS loader and not in v8?

@jkrems

This comment has been minimized.

Copy link
Contributor

@jkrems jkrems commented Jan 9, 2020

@ljharb Since the same (bad) behavior can be seen without wrapSafe, I think there's definitely still a V8 bug. Once the V8 behavior is fixed, we could see if there's a secondary bug in node as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.