Skip to content

util: improve inspect - #20802

Closed
BridgeAR wants to merge 4 commits into
nodejs:masterfrom
BridgeAR:improve-error-inspection
Closed

util: improve inspect#20802
BridgeAR wants to merge 4 commits into
nodejs:masterfrom
BridgeAR:improve-error-inspection

Conversation

@BridgeAR

@BridgeARBridgeAR commented May 17, 2018

Copy link
Copy Markdown
Member

Please check the commit messages for the details.

Refs: #20253

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-botnodejs-github-bot added the util Issues and PRs related to the built-in util module. label May 17, 2018

@addaleaxaddaleax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM as semver-major

@addaleaxaddaleax added the semver-major PRs that contain breaking changes and should be released in the next major version. label May 17, 2018
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 17, 2018
@BridgeAR
BridgeAR requested a review from a teamMay 17, 2018 15:02

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Trott

Copy link
Copy Markdown
Member

Would be curious to see CITGM results as I could see this impacting test suites. (But maybe not?)

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@addaleax about this being semver-major: we actually have the following in our docs:

The output of util.inspect may change at any time and should not be depended upon programmatically. 

So I personally do not think this is semver-major. When added, it was somewhat meant for changes like these as far as I can tell.

@addaleax

Copy link
Copy Markdown
Member

@BridgeAR Yes, this is definitely in the “erring on the side of caution” category. I know that people shouldn’t depend on it, but I’m not sure this change is trivial enough to have a reasonable expectation that it doesn’t break people’s code.

If there is a good reason for this not being semver-major (as in, a significant advantage for us), we can remove the label.

CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1418/

This aligns the visualization of an error with no stack traces set
to zero just as it is done in case the error has no stack trace.
When inspecting nested objects some times a whitespace was added at
the end of a line. This fixes this erroneous space.
Besides that the `breakLength` was not followed if a single property
was longer than the breakLength. It will now break a single property
into the key and value in such cases.
Error stacks and multiline error messages were not correct indented.
This is fixed by this patch.
When inspecting errors with extra properties while setting the
compact option to false, it will now return:
[Error: foo] {
at repl:1:5
at Script.runInThisContext (vm.js:89:20)
bla: true
}
Instead of:
Error: foo
at repl:1:5
at Script.runInThisContext (vm.js:91:20) {
bla: true
}
@BridgeAR
BridgeARforce-pushed the improve-error-inspection branch from 04c0c48 to 9c1d559CompareMay 20, 2018 20:27
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Rebased due to conflicts.

New CI https://ci.nodejs.org/job/node-test-pull-request/14988/

Since the conflicts required some more work, PTAL.

@addaleax one main benefit would be easier backports.

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

As a note: nothing seem to show up on CITGM.

@mcollina

Copy link
Copy Markdown
Member

Still LGTM

BridgeAR added a commit to BridgeAR/node that referenced this pull request May 21, 2018
This aligns the visualization of an error with no stack traces set
to zero just as it is done in case the error has no stack trace.
PR-URL: nodejs#20802
Refs: nodejs#20253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
BridgeAR added a commit to BridgeAR/node that referenced this pull request May 21, 2018
When inspecting nested objects some times a whitespace was added at
the end of a line. This fixes this erroneous space.
Besides that the `breakLength` was not followed if a single property
was longer than the breakLength. It will now break a single property
into the key and value in such cases.
PR-URL: nodejs#20802
Refs: nodejs#20253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
BridgeAR added a commit to BridgeAR/node that referenced this pull request May 21, 2018
Error stacks and multiline error messages were not correct indented.
This is fixed by this patch.
PR-URL: nodejs#20802
Refs: nodejs#20253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
BridgeAR added a commit to BridgeAR/node that referenced this pull request May 21, 2018
When inspecting errors with extra properties while setting the
compact option to false, it will now return:
[Error: foo] {
at repl:1:5
at Script.runInThisContext (vm.js:89:20)
bla: true
}
Instead of:
Error: foo
at repl:1:5
at Script.runInThisContext (vm.js:91:20) {
bla: true
}
PR-URL: nodejs#20802
Refs: nodejs#20253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Thanks.

Landed in 7f0f978...c041a2e 🎉

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@addaleax I still think it would be best not to have this as semver-major.

@addaleax

Copy link
Copy Markdown
Member

@BridgeAR If you feel strongly about this, you can remove the label… I don’t think this is something we’d want to backport to an LTS line, though

@addaleaxaddaleax mentioned this pull request May 22, 2018
@BridgeAR
BridgeAR deleted the improve-error-inspection branch January 20, 2020 11:33
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.utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@BridgeAR@Trott@addaleax@mcollina@jasnell@trivikr@nodejs-github-bot