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 <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
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