-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
errors: add useOriginalName to internal/errors #22556
Conversation
Also for context on why we use our internal error system for the URL errors: #11299 |
There was also a discussion about restoring the behavior of |
or...maybe we have to leave the error names alone, at least for errors thrown from Web APIs :/ Refs: https://heycam.github.io/webidl/#dfn-exception-error-name
|
Not really a fan of this and really prefer to leave the internal/error names as they are currently. However, if this is just for testing, then definitely won't block |
@jasnell Yeah this is just a hack for testing with the WPT harness directly instead of using our mocks. I am not entirely sure if it's technically a bug in our implementation (which means we need to fix it for users), or just a quirk that we need to deal with if we want to use the WPT harness in our own tests though, but it doesn't harm to have a workaround before we figure that out |
lib/internal/errors.js
Outdated
// These are exported only to facilitate testing. | ||
E, | ||
get useOriginalName() { return useOriginalName; }, | ||
set useOriginalName(value) { useOriginalName = value; } | ||
}; |
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.
Instead of adding the useOriginalName
couldn't you create a new error helper for more Web Platform related errors separate from the makeNodeErrorWithCode
one?
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.
@jdalton I would if we decide to leave the names alone for those errors...but doesn't seem to worth it if it's just to work around the WPT harness and it's only for testing
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.
@joyeecheung Is it just a test harness thing are is the WPT fail hinting that URL errors should not have custom name's other than those of the builtin errors? If it means URL
is not spec compliant then it's an issue for Node. If it is unspec'd then a bug should be filed for WPT.
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.
See #11299 If you feel strongly about this feel free to reopen that issue or open a new one. If we were to fix that, it has to be semver-major. This PR is just a work around so that we can update the tests without a semver-major change - I would rather not label a bunch of upcoming test update with semver-major and make them a backport burden.
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.
Changing user accessible error APIs is not the answer here.
@jdalton Can you elaborate on your reasoning behind this? We have been exposing user-accessible APIs - albeit internals that are behind flags - to facilitate testing, like the |
This is a test harness concern and not worth moving into exposed APIs. I've given you a path forward that doesn't involving touching Node error APIs. Depending on where the fault is you can file a bug on WPT or work with Node to correct its errors. If it requires a major bump for Node then so be it. The WPT tests can be held until then. |
@joyeecheung the issue is #20253. I only found a single way to consistently adding the error code to the stack trace while keeping the name as is: directly after creating the error (or on creation) the name is set to Other than that, the current implementation is AFAIK the only one possible. |
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.
this looks a-okay to me
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.
Since this is internal, I am fine with it for now. We can still revise the solution if we find something better.
So LGTM.
I would agree if this is a public API, but it is an internal API that is only accessible with the EDIT: it appears I was on a outdated branch...the current number of |
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.
Oh I see. I misunderstood where the useOriginalName
getter/setters lived.
IMHO that's A Ok. At least for unit testing. Being able to "mock out" parts of the system is very important for predictable testing. |
|
lib/internal/errors.js
Outdated
@@ -437,7 +442,10 @@ module.exports = { | |||
getMessage, | |||
SystemError, | |||
codes, | |||
E // This is exported only to facilitate testing. | |||
// These are exported only to facilitate testing. |
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.
Could you add this This allows us to tell the type of the errors without using instanceof, which is necessary in WPT harness.
to the comment.
Ping @joyeecheung |
This allows us to tell the type of the errors without using instanceof, which is necessary in WPT harness.
a831e50
to
2742d39
Compare
Addressed @refack 's comments. |
I am going to land this tomorrow if there are no more comments etc. |
Thank you for following up. |
Landed in e692a09, thanks! |
This allows us to tell the type of the errors without using instanceof, which is necessary in WPT harness. PR-URL: #22556 Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
This allows us to tell the type of the errors without using instanceof, which is necessary in WPT harness. PR-URL: #22556 Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
This allows us to tell the type of the errors without using instanceof, which is necessary in WPT harness. PR-URL: #22556 Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
This allows us to tell the type of the errors without using instanceof, which is necessary in WPT harness. PR-URL: #22556 Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
This allows us to tell the type of the errors without using
instanceof, which is necessary in WPT harness.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes