Skip to content

Conversation

@cola119
Copy link
Member

@cola119cola119 commented Jul 5, 2022

Currently util.inspect has the inline access to Symbol.iterator to 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 in operator to be able to inspect correctly.

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jul 5, 2022
Copy link
Member

@bnoordhuisbnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 '...')

@aduh95aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 5, 2022
Copy link
Member

@BridgeARBridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BridgeAR
Copy link
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.

@cola119
Copy link
MemberAuthor

cola119 commented Jul 5, 2022

@bnoordhuis The below reproduces the reported behavior (v18.4.0) for the same reason.

util.inspect({a: {get[Symbol.iterator](){throwError('boom');},},});
> util.inspect({a:{get [Symbol.iterator](){throw Error("boom") }}}) Uncaught Error [ERR_INTERNAL_ASSERTION]: Error: boom at get [Symbol.iterator] (REPL2:1:49) at formatRaw (node:internal/util/inspect:862:12) at formatValue (node:internal/util/inspect:822:10) at formatProperty (node:internal/util/inspect:1824:11) at formatRaw (node:internal/util/inspect:1035:9) at formatValue (node:internal/util/inspect:822:10) at Object.inspect (node:internal/util/inspect:347:10) at REPL2:1:6 at Script.runInThisContext (node:vm:130:12) at REPLServer.defaultEval (node:repl:574:29) This is caused by either a bug in Node.js or incorrect usage of Node.js internals. Please open an issue with this stack trace at https://github.com/nodejs/node/issues at __node_internal_captureLargerStackTrace (node:internal/errors:477:5) at new NodeError (node:internal/errors:388:5) at Function.fail (node:internal/assert:20:9) at handleMaxCallStackSize (node:internal/util/inspect:1464:10) at formatRaw (node:internal/util/inspect:1042:12) at formatValue (node:internal/util/inspect:822:10) at Object.inspect (node:internal/util/inspect:347:10){code: 'ERR_INTERNAL_ASSERTION' } 

@cola119
Copy link
MemberAuthor

Maybe I'm misunderstanding the cause, but anyway @BridgeAR, thanks for the confirmation.

@BridgeAR
Copy link
Member

@cola119 it is one possibility to trigger the issue. There are other ways to trigger the internal error as well.

@aduh95aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 7, 2022
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 7, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 9, 2022
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 9, 2022
@nodejs-github-botnodejs-github-bot merged commit 550e814 into nodejs:mainJul 9, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 550e814

targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #43683 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
@targostargos mentioned this pull request Jul 12, 2022
targos pushed a commit that referenced this pull request Jul 20, 2022
PR-URL: #43683 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #43683 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
@targostargos mentioned this pull request Aug 3, 2022
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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@cola119@BridgeAR@nodejs-github-bot@bnoordhuis@aduh95@RaisinTen