util: avoid inline access to Symbol.iterator#43683
Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom Jul 9, 2022
Merged
util: avoid inline access to Symbol.iterator#43683nodejs-github-bot merged 1 commit intonodejs:mainfrom
nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
bnoordhuis
approved these changes
Jul 5, 2022
Member
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM, although I can't reproduce the reported behavior (which is against v17.x) with v18.2.0. This is what I see instead:
> util.inspect({get [Symbol.iterator](){ throw Error("boom") }})
Uncaught Error: boom
at get [Symbol.iterator] (REPL1:1:46)
at formatRaw (node:internal/util/inspect:857:12)
at formatValue (node:internal/util/inspect:817:10)
at Object.inspect (node:internal/util/inspect:347:10)
(Same with node -p '...')
aduh95
approved these changes
Jul 5, 2022
Member
|
It does not fix: #41244 I removed that from the description above. I have a fix for that and am going to open a PR later on. |
Member
Author
|
@bnoordhuis The below reproduces the reported behavior (v18.4.0) for the same reason. util.inspect({
a: {
get [Symbol.iterator]() {
throw Error('boom');
},
},
}); |
Member
Author
|
Maybe I'm misunderstanding the cause, but anyway @BridgeAR, thanks for the confirmation. |
Member
|
@cola119 it is one possibility to trigger the issue. There are other ways to trigger the internal error as well. |
RaisinTen
approved these changes
Jul 5, 2022
Collaborator
Collaborator
Collaborator
21 tasks
Collaborator
|
Landed in 550e814 |
20 tasks
targos
pushed a commit
that referenced
this pull request
Jul 12, 2022
PR-URL: #43683 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
targos
pushed a commit
that referenced
this pull request
Jul 20, 2022
PR-URL: #43683 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
targos
pushed a commit
that referenced
this pull request
Jul 31, 2022
PR-URL: #43683 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
guangwong
pushed a commit
to noslate-project/node
that referenced
this pull request
Oct 10, 2022
PR-URL: nodejs/node#43683 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently
util.inspecthas the inline access toSymbol.iteratorto check if the value to be inspected is an iterator, but it could throw when the value of[Symbol.iterator]throws(has) an error.This PR replaced the inline access with
inoperator to be able to inspect correctly.