-
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
errors: assign error code to bootstrap_node created error #11298
Conversation
This is perhaps misleading as these are not necessarily "native" as in "C/C++" modules. |
Yep. It certainly is. Basing this off the existing wording (I did not change the error message at all). Do you have a suggestion for an alternative? |
doc/api/errors.md
Outdated
@@ -563,6 +563,17 @@ found [here][online]. | |||
encountered by [`http`][] or [`net`][] -- often a sign that a `socket.end()` | |||
was not properly called. | |||
|
|||
<a id="nodejs-error-codes"> | |||
## Node.js Error Codes | |||
|
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.
We probably need a section explaining the new error system(like the section on "system errors" above mentioning those would have error.code
, error. errno
and error. syscall
properties, then list the error codes). Going straight to error code descriptions seems pretty confusing if people read it from the top to the bottom...
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.
Yep, I agree. I was thinking of doing that in a separate PR
@jasnell @Fishrock123 do we have a name for the |
LGTM with the naming sorted out |
@joyeecheung ... not really with regards to naming. Perhaps |
Sorry, I wasn't being clear. I meant I am fine with I do think |
doc/api/errors.md
Outdated
@@ -563,6 +563,17 @@ found [here][online]. | |||
encountered by [`http`][] or [`net`][] -- often a sign that a `socket.end()` | |||
was not properly called. | |||
|
|||
<a id="nodejs-error-codes"> |
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.
Why don't we let the tools to generate the id for all these? It would be consistent that way.
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.
Because these anchors need to be consistent and predictable even if the structure of the document changes. Doing it this way ensures that the anchors will not change.
lib/internal/errors.js
Outdated
@@ -85,4 +85,5 @@ module.exports = exports = { | |||
// | |||
// Note: Please try to keep these in alphabetical order | |||
E('ERR_ASSERTION', (msg) => msg); | |||
E('ERR_UNKNOWN_NATIVE_MODULE', (id) => `No such built-in module: ${id}`); |
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.
Now that the error message is updated to No such built-in module
, the error code should be changed accordingly?
dcdda51
to
40637de
Compare
Updated. PTAL |
40637de
to
7a94c93
Compare
Ping @nodejs/ctc ... can I get a review on this? |
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
7a94c93
to
7707ed9
Compare
This is no longer blocked. PR updated. |
I think this is a misnomer, IIRC that module does not need to be built-in to possibly hit this path? (Don't all native modules hit this or something?) Note: I understand it is called "NativeModule as in "builtin natives". |
Not that I'm aware of. In every condition that I was able to find, most users will only see the "Cannot find module" error. This appears to be hit only in very specific cases involving the built-in modules. I could be wrong, but that's what I've been able to see. There's aren't even any test cases that I can see that trigger/test this. |
@jasnell FWIW, I have only ever hit this path when I accidentally deleted a js file from node.gyp... |
lib/internal/bootstrap_node.js
Outdated
// Model the error off the internal/errors.js model, but | ||
// do not use that module given that it could actually be | ||
// the one causing the error if there's a bug in Node.js | ||
const err = new Error(`No such built-in module ${id}`); |
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.
Nit: There is a colon in errors.js file
7707ed9
to
491185c
Compare
@Fishrock123 ... are you satisfied with this? |
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 with a nit
lib/internal/bootstrap_node.js
Outdated
// the one causing the error if there's a bug in Node.js | ||
const err = new Error(`No such built-in module: ${id}`); | ||
err.code = 'ERR_UNKNOWN_BUILTIN_MODULE'; | ||
err.name = 'Error[ERR_UNKNOWN_BUILTIN_MODULE]'; |
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.
nit: there should be a space now that 7b4a72d has landed.
This does not use the internal/errors.js module because the error in question may actually be *caused* by an attempt to load internal/errors.js. This error should only be encountered in the case of a bug within Node.js itself. Ref: nodejs#11273
491185c
to
de5c440
Compare
This does not use the internal/errors.js module because the error in question may actually be *caused* by an attempt to load internal/errors.js. This error should only be encountered in the case of a bug within Node.js itself. PR-URL: #11298 Ref: #11273 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Landed in 251e5ed |
Hmm, ok sounds good to me. Belated LGTM. |
This does not use the internal/errors.js module because the error in question may actually be caused by an attempt to load internal/errors.js. This error should only be encountered in the case of a bug within Node.js itself.
Ref: #11273
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
errors, src