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

[8.x] assert.rejects fails with confusing error message #27185

Closed
gcampax opened this issue Apr 11, 2019 · 2 comments
Closed

[8.x] assert.rejects fails with confusing error message #27185

gcampax opened this issue Apr 11, 2019 · 2 comments
Labels
assert Issues and PRs related to the assert subsystem. confirmed-bug Issues with confirmed bugs.

Comments

@gcampax
Copy link
Contributor

gcampax commented Apr 11, 2019

  • Version: latest 8.* series
  • Platform: not relevant
  • Subsystem: assert

The API of assert.rejects is different between the 10.* series and the 8.* series, because the backported 8.* version does not accept a Promise as first argument, it requires a Function that returns a rejected promise.
If you misuse the API, though, you get a confusing error message:

TypeError: errors.ERR_INVALID_ARG_TYPE is not a constructor
at waitForActual (assert.js:723:11)
at Function.rejects (assert.js:799:31)

This is because at

throw new errors.ERR_INVALID_ARG_TYPE('block', 'Function', block);
the throw line is incorrect.

@BridgeAR
Copy link
Member

Hm, yes. In Node.js v8 we do not have the new Error system and we did not see that while backporting.

I'll try to get a fix into v8.16.0 (#26933).

@BridgeAR BridgeAR added confirmed-bug Issues with confirmed bugs. assert Issues and PRs related to the assert subsystem. labels Apr 11, 2019
BridgeAR added a commit to BridgeAR/node that referenced this issue Apr 12, 2019
This fixes a regression for an error case with `assert.rejects` and
`assert.doesNotReject`.

Fixes: nodejs#27185
MylesBorins pushed a commit that referenced this issue Apr 16, 2019
This fixes a regression for an error case with `assert.rejects` and
`assert.doesNotReject`.

Fixes: #27185

PR-URL: #27202
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Beth Griggs <[email protected]>
@MylesBorins
Copy link
Contributor

Fix went out in 8.16.0

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

No branches or pull requests

3 participants