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

assert: filename may be undefined in filename.endsWith('.js') #20847

Closed
jeysal opened this issue May 20, 2018 · 0 comments
Closed

assert: filename may be undefined in filename.endsWith('.js') #20847

jeysal opened this issue May 20, 2018 · 0 comments
Labels
assert Issues and PRs related to the assert subsystem. confirmed-bug Issues with confirmed bugs.

Comments

@jeysal
Copy link
Contributor

jeysal commented May 20, 2018

  • Version: v10.1.0
  • Platform: Linux arch-seckinger 4.16.9-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Thu May 17 02:10:09 UTC 2018 x86_64 GNU/Linux
  • Subsystem: assert

Apparently introduced by #18322.
I'm working on a PR to fix this.

code

new Function("assert", "assert(1 === 2);")(require("assert"));

expected behavior

(this is what happens with node 6, 7, 8 and 9)
throws an AssertionError: false == true

actual behavior

(with node 10)
throws

assert.js:163
  if (filename.endsWith('.js') && NativeModule.exists(filename.slice(0, -3))) {
               ^

TypeError: Cannot read property 'endsWith' of undefined
@BridgeAR BridgeAR added confirmed-bug Issues with confirmed bugs. assert Issues and PRs related to the assert subsystem. labels May 20, 2018
jeysal added a commit to jeysal/node that referenced this issue May 21, 2018
When generating an assertion error message,
`filename` might be undefined,
e.g. if `assert` is called in `eval`.

Handle this case gracefully instead of failing with
`Cannot read property 'endsWith' of undefined`.

Fixes: nodejs#20847
targos pushed a commit that referenced this issue May 25, 2018
When generating an assertion error message,
`filename` might be undefined,
e.g. if `assert` is called in `eval`.

Handle this case gracefully instead of failing with
`Cannot read property 'endsWith' of undefined`.

Fixes: #20847

PR-URL: #20848
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. confirmed-bug Issues with confirmed bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants