-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
assert: move assertion part in extra file #20486
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
Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
errors: move functions to error code
This makes sure the functions are actually directly beneat the specification of an error code. That way it is not necessary to jump around when looking at the functionality.
- Loading branch information
commit 4c9c77d9954d74541f597fb39afc3776985a971c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
In general I think it's pretty odd to use
assertininternal/errors.js. My impression is thatassertin our own code is used to guard against potential user-land monkey-patching gone wrong, but the internal errors are not open to monkey-patching in any way, and most of the internal error code should be simple enough to debug without assertions (even if they are not that simple now, at least they are supposed to be, sinceinternal/errorsis required by almost every module). It is especially odd in cases like this where the formatter ofERR_INVALID_ARG_TYPEis effectively guarding against aERR_INVALID_ARG_TYPE. Even if we want to guard against our own code, we should probably be usingDCHECKmacros that are only available in debug mode instead ofassertsThere 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.
I did not add anything new here. Before it was just about using
internalAssertinstead. In this specific case I do not think it provides a lot of benefit to check this (especially since we do not check input types in any other error). There are a few cases in here that make it much easier to implement the error codes though. I found a few cases that were wrong when validating the passed through arguments and I definitely would like to keep that.That aside: when I worked on #20567 I also tried to remove
assert. As far as I see it is partially used in places where we would now use other errors from in here and partially to prevent malicious values getting through to the C++ layer (you could call it "monkey-patching gone wrong" ;-) ).Using CHECK and DCHECK for these things would definitely be one way to deal with these. There is just one problem: using e.g., DCHECK means our regular builds while coding will not show any errors and we would only see the issues in the CI. I am not sure if that is fine.
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.
In general: I guess this discussion is not really about the specific code change?