-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
util: safely inspect getter errors whose message throws #60684
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
util: safely inspect getter errors whose message throws #60684
Conversation
|
Note that I based the behaviour from @legendecas comment in this related PR: #60139 (review)
|
ab97c2a to
09d8f0b
Compare
89f0e53 to
9b05e4e
Compare
yvele
left a comment
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.
@aduh95 @ljharb this is way more straighforward.
I fully rely on inspect to get the error description.
The error not only shows the error message but the whole (indented) stack:
{
foo: [Getter: <Inspection threw (Error: Oops
at get foo (/foo/node_modules/foo.js:2:7)
at get bar (/foo/node_modules/bar.js:827:30))>]
}
I think that looks pretty nice and explicit👍
What do you think?
aduh95
left a comment
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.
+1 on the much simpler implementation
|
nit: if you could add a test with recursion (i.e. a case where the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60684 +/- ##
==========================================
- Coverage 88.55% 88.54% -0.02%
==========================================
Files 703 703
Lines 208259 208259
Branches 40178 40164 -14
==========================================
- Hits 184425 184395 -30
- Misses 15855 15867 +12
- Partials 7979 7997 +18
🚀 New features to boost your workflow:
|
e0cae36 to
04bb6b2
Compare
ea37cc0 to
83db54c
Compare
df7e577 to
a683626
Compare
Commit Queue failed- Loading data for nodejs/node/pull/60684 ✔ Done loading data for nodejs/node/pull/60684 ----------------------------------- PR info ------------------------------------ Title util: safely inspect getter errors whose message throws (#60684) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch yvele:defensive-inspect-getter-error-message -> nodejs:main Labels util, author ready, needs-ci Commits 16 - util: safely inspect getter errors whose message throws - fixup! util: add test cases with getters throwing uncommon values - fixup! util: handle uncommon thrown errors - fixup! util: ESLint exception line styling - fixup! util: add test case with getter throwing undefined - fixup! util: implement consistent `inspect(err)` - fixup! util: improve test readability - fixup! util: rely in inspect to describe error - fixup! util: typo in test comment - fixup! util: handle inspect options - fixup! util: fix error catch indentation - fixup! util: add infinite recursion test case - fixup! util: improve test readability with an array - fixup! util: improve recursive test readability - fixup! util: add depth 2 test cases - fixup! util: add comment explaining stackTraceLimit override in test Committers 1 - Yves M <4225430+yvele@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/60684 Fixes: https://github.com/nodejs/node/issues/60683 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/60684 Fixes: https://github.com/nodejs/node/issues/60683 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> -------------------------------------------------------------------------------- ℹ This PR was created on Tue, 11 Nov 2025 19:27:57 GMT ✔ Approvals: 1 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/60684#pullrequestreview-3504941867 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2025-11-27T09:36:15Z: https://ci.nodejs.org/job/node-test-pull-request/70329/ - Querying data for job/node-test-pull-request/70329/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 60684 From https://github.com/nodejs/node * branch refs/pull/60684/merge -> FETCH_HEAD ✔ Fetched commits as ce29481a527e..dd6be927896a -------------------------------------------------------------------------------- [main e8271737e0] util: safely inspect getter errors whose message throws Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Tue Nov 11 20:46:56 2025 +0100 2 files changed, 25 insertions(+), 1 deletion(-) [main 035cd606bc] fixup! util: add test cases with getters throwing uncommon values Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Wed Nov 12 10:53:08 2025 +0100 1 file changed, 54 insertions(+), 1 deletion(-) [main 95baef3772] fixup! util: handle uncommon thrown errors Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Wed Nov 12 11:07:02 2025 +0100 2 files changed, 8 insertions(+), 7 deletions(-) [main 043eb8ec04] fixup! util: ESLint exception line styling Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Wed Nov 12 11:11:02 2025 +0100 1 file changed, 3 insertions(+), 3 deletions(-) [main 9cb7b3096c] fixup! util: add test case with getter throwing undefined Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Wed Nov 12 11:20:56 2025 +0100 1 file changed, 7 insertions(+) [main 2de1b535df] fixup! util: implement consistent `inspect(err)` Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Wed Nov 12 13:22:02 2025 +0100 2 files changed, 100 insertions(+), 53 deletions(-) [main 889242c169] fixup! util: improve test readability Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Wed Nov 12 14:07:55 2025 +0100 1 file changed, 3 insertions(+), 3 deletions(-) [main ba780b4546] fixup! util: rely in inspect to describe error Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Tue Nov 18 19:53:14 2025 +0100 2 files changed, 24 insertions(+), 46 deletions(-) [main 30f22a9131] fixup! util: typo in test comment Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Sat Nov 22 15:04:46 2025 +0100 1 file changed, 1 insertion(+), 1 deletion(-) [main 979c15a4bb] fixup! util: handle inspect options Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Mon Nov 24 10:43:34 2025 +0100 2 files changed, 153 insertions(+), 14 deletions(-) [main d7df413558] fixup! util: fix error catch indentation Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Mon Nov 24 10:53:54 2025 +0100 2 files changed, 16 insertions(+), 18 deletions(-) [main ddd68cef77] fixup! util: add infinite recursion test case Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Mon Nov 24 11:15:10 2025 +0100 1 file changed, 37 insertions(+) [main 91bbcecd7a] fixup! util: improve test readability with an array Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Mon Nov 24 14:27:42 2025 +0100 1 file changed, 49 insertions(+), 46 deletions(-) [main 4602a59137] fixup! util: improve recursive test readability Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Tue Nov 25 09:18:32 2025 +0100 1 file changed, 29 insertions(+), 100 deletions(-) [main d4bd6e4ed2] fixup! util: add depth 2 test cases Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Tue Nov 25 11:58:52 2025 +0100 1 file changed, 39 insertions(+), 25 deletions(-) [main 0036451488] fixup! util: add comment explaining stackTraceLimit override in test Author: Yves M <4225430+yvele@users.noreply.github.com> Date: Tue Nov 25 12:13:48 2025 +0100 1 file changed, 2 insertions(+) ✔ Patches applied There are 16 commits in the PR. Attempting autorebase. (node:2267) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated. (Use `node --trace-deprecation ...` to show where the warning was created) Rebasing (2/32) Executing: git node land --amend --yes --------------------------------- New Message ---------------------------------- util: safely inspect getter errors whose message throwshttps://github.com/nodejs/node/actions/runs/19733585643 |
|
Landed in ca5956c |
Fixes: #60683
Previously, when a getter threw, only the message was output. Now
inspectcorrectly outputs the full error according to the specified options.