-
Notifications
You must be signed in to change notification settings - Fork 30k
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
test: verify detail exception messages in addons-napi/test_constructor #14318
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green.
Landed in e6eb5c0. |
Test errors thrown in addons-napi/test_constructor more specifically. PR-URL: #14318 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Test errors thrown in addons-napi/test_constructor more specifically. PR-URL: #14318 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
What's the reasoning behind this change? When using node-chakracore this test was succeeding but now it fails since the specific error message reported by the engine is different. Does N-API intend to specify the particular error messages that are raised? |
The project treats Error message changes as breaking changes. This is because people often need to sniff error message text in production code to make a determination of what to do with a caught error. The hope is that we can eventually drop that stance after there's been sufficient time given for the But we're not there yet. Until then, we encourage checking specific error messages in the tests so that the tests break when the messages change (and we can flag the change as a breaking change). Can't speak for other Collaborators, but I'd certainly consider** (for example) a proposal that we relax that for error types that are more specific than * At least, that seems to be the hope among most folks. I'm personally on the fence. A code for invalid argument type will still require the end user to sniff the message text to figure out which argument is invalid, thus making changes to messages still a potentially breaking change for responsibly-written code. ** No promise of supporting the proposal, of course. But I'd certainly give it an honest look! |
Thanks for the response. I've already tweaked the test in the node-chakracore repo to account for different error strings (see nodejs/node-chakracore@2f9535c?w=1) but it is good to know that error strings are considered to be part of the API surface. I'm not sure that sniffing strings will always be useful though, since as you can see from the change I made the error message that chakracore gives is significantly different to the error given by v8. |
While I understand that error message changes are currently treated as breaking changes, I was under the impression (based on PRs like #13988 from @mhdawson) that the intent was to move the community away from relying on them and instead to rely on error codes. Is that not the case (apologies for hijacking this PR- please let me know if I should just open another issue for this discussion) |
@digitalinfinity You're exactly right. That is the intention. |
@MSLaguana Actually, this raises an important point. I think we concluded that error messages that were generated by V8 would be exempted from the "breaking change if the message changes" rule because we can't really control what V8 does with its error messages. @nodejs/ctc Am I right to recall that? If so, then a case could certainly be made that these really should just check for |
@Trott you are right. See the last paragraph of https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#breaking-changes:
|
Test errors thrown in addons-napi/test_constructor more specifically. PR-URL: nodejs#14318 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Test errors thrown in addons-napi/test_constructor more specifically. Backport-PR-URL: #19447 PR-URL: #14318 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
[JSConf CN Code&Learn] Verify detail exception messages in addons-napi/test_constructor.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
no, just update tests.