GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert 17907: util: change inspect depth default by addaleax · Pull Request #20017 · nodejs/node

Conversation

@addaleax

@addaleax addaleax commented Apr 13, 2018

Copy link
Copy Markdown
Member
  • Revert "util: change util.inspect depth default"

    This reverts commit b994b8e.

    This caused regressions in ecosystem code. While the change originally
    was semver-major and could be postponed until after Node.js 10,
    I think reverting it is a good choice at this point.

    Also, I personally do not think defaulting to a shallow inspect
    is a bad thing at all – quite the opposite: It makes util.inspect()
    give an overview of an object, rather than providing a full
    display of its contents. Changing the depth default to infinity
    fundamentally changed the role that util.inspect() plays,
    and makes output much more verbose and thus at times unusable
    for console.log()-style debugging.

    Fixes: npm: last nightly / v8-canary make npm update unusable #19405
    Refs: util: change inspect depth default #17907

  • Revert "util: change %o depth default"

    This reverts commit 8f15309.

(#19994 also has a Fixes: tag for #19405, but it’s independent from this PR and is not uncontroversial)

  • 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@addaleax
addaleax requested review from a team and BridgeAR April 13, 2018 19:57
@nodejs-github-bot nodejs-github-bot added repl Issues and PRs related to the REPL subsystem. util Issues and PRs related to the built-in util module. labels Apr 13, 2018
@addaleax

addaleax commented Apr 13, 2018

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Apr 13, 2018

Copy link
Copy Markdown
Member

While this option definitely needs to stay on the table, I'm not yet ready to agree that this is the right thing to do... for a couple of reasons:

  1. The issue with npm update illustrates a fundamental weakness of util.inspect() with overly large objects. The npm code takes an object that with a depth of 8 generates a string that is over 6.6 MB in size and over 81k lines long. Any object, even with a depth of 2, could end up with precisely the same issue. The problem is not so much the default depth but the depth-first string-and-array-munging and memory-eating algorithm that is used to generate the string. We should investigate a much more efficient algorithm.

  2. The issue in user-code can be mitigated with a semver-patch fix to explicitly set the depth to 2 as opposed to relying on the default.

  3. Sending multi-megabyte large objects to a sync function for serialization is never a great idea.

I'm perfectly fine with not including the original commit in 10.0.0 but before we revert we should look at alternatives.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Apr 13, 2018

Copy link
Copy Markdown
Member Author

We should investigate a much more efficient algorithm.

Yes, and I like the suggestion of a maximum string length that @BridgeAR brought up – That’s not an easy thing to do, though.

Also, from a purely pragmatical point of view, the current situation would be that if we don’t land both #17907 and a revert on v10.x, there are going to be other semver-major changes that would be help up because of merge conflicts (like WeakMap/WeakSet support).

The issue in user-code can be mitigated with a semver-patch fix to explicitly set the depth to 2 as opposed to relying on the default.

Yea, I don’t think relying on something that has been the default for literally 8+ years qualifies as an “issue in user-code” in any way.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Apr 13, 2018

Copy link
Copy Markdown
Member Author

Also: Even if we do the maximum string length approach or something like that, I still think this is the right thing to do (for the reasons given in the commit message).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Apr 13, 2018

Copy link
Copy Markdown
Member

As I said, I'm all for not including this in 10.0.0. I'd like to just do a bit more investigation of other options before we revert.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott approved these changes Apr 13, 2018
View reviewed changes
@Trott

Trott commented Apr 13, 2018

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Apr 14, 2018

Copy link
Copy Markdown
Member

👍 on not including the change of default in 10, but let's wait a bit more before landing this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apapirovski

apapirovski commented Apr 14, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Instead of a revert, could we just back this out of v10 and have it be scheduled to land in v11? Or do we want each major to represent the state of master at the related point in time?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Apr 14, 2018

Copy link
Copy Markdown
Member Author

@apapirovski Yes, backing it out is the current plan.

Also, as said above, there are other factors that played into the decision to open a revert (unblocking other PRs that wouldn’t go into 10.x + the change in semantics not being a good one).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Apr 14, 2018

Copy link
Copy Markdown
Member Author

but let's wait a bit more before landing this.

@mcollina Can you give a ballpark number for the time frame you had in mind? (And, ideally, a reason would be nice as well…)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TimothyGu
TimothyGu approved these changes Apr 14, 2018
View reviewed changes
@mcollina

mcollina commented Apr 14, 2018

Copy link
Copy Markdown
Member

After 10 goes out and we can discuss about it with less urgency? There is a lot of traffic on a lot of issues atm.
Sincerely, I’ve seen this API being misused and causing a lot of production issues, and not being really useful.
I think that printing full depth is actually a good improvement in usability, as I never founs the output particularly useful in complex cases.

I think something should be done about it. This might be the path to go, and then we do something else instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Apr 14, 2018

Copy link
Copy Markdown
Member Author

@mcollina I’m sorry, I don’t mean to imply that landing this PR would mean an end of the discussion. I do agree that util.inspect() output could often be improved.

But, unfortunately, there is urgency in the sense that we do need this revert to land before Node 10, either on master or on v10.x-staging. We can’t just rebase out the commits, there have been over 1000 commits since and there would be far too many merge conflicts or commits that we’d have to skip (I tried it).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Apr 14, 2018

Copy link
Copy Markdown
Member

@addaleax ... Can you open a separate revert PR against v10.x-staging? I'll get it landed on Tuesday when I do the next round of updates on that branch.

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Apr 14, 2018

Copy link
Copy Markdown
Member Author

@jasnell That also gives merge conflicts because v10.x-staging isn’t quite caught up to master yet, so if I were to open a revert “backport” PR now we’d just have to take care of those later again … let me know when you’ve updated the branch and I can open a PR then, if that’s ok with you

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Apr 14, 2018 via email

Copy link
Copy Markdown
Member
Ok that works On Apr 14, 2018 14:48, "Anna Henningsen" <[email protected]> wrote: @jasnell <https://github.com/jasnell> That also gives merge conflicts because v10.x-staging isn’t quite caught up to master yet, so if I were to open a revert “backport” PR now we’d just have to take care of those later again … let me know when you’ve updated the branch and I can open a PR then, if that’s ok with you — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#20017 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAa2eVL0drGkZSZNXtwZqGPUnn13tqz8ks5tom6XgaJpZM4TUG5b> .
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig approved these changes Apr 14, 2018
View reviewed changes
joyeecheung
joyeecheung approved these changes Apr 15, 2018
View reviewed changes
@BridgeAR

BridgeAR commented Apr 16, 2018

Copy link
Copy Markdown
Member

Just marking this explicit PR as blocked for now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR added the blocked PRs that are blocked by other issues or PRs. label Apr 16, 2018
@jasnell jasnell added blocked PRs that are blocked by other issues or PRs. and removed blocked PRs that are blocked by other issues or PRs. labels Apr 16, 2018
@jasnell

jasnell commented Apr 16, 2018

Copy link
Copy Markdown
Member

@addaleax .... I just updated v10.x-staging and this now lands clean there. I'll open a second PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell mentioned this pull request Apr 16, 2018
[10.x] Revert 17907: util: change inspect depth default #20089
Closed
4 tasks done
@addaleax

addaleax commented Apr 17, 2018

Copy link
Copy Markdown
Member Author

@BridgeAR I think this is no longer blocked after #20089, if I understood your intention with adding the label correctly?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request May 11, 2018
@addaleax @BridgeAR
test: make sure linked lists are inspectable with defaults
5096e24
Make sure that a long singly-linked list can be passed
to `util.inspect()` without causing a stack overflow.

PR-URL: nodejs#20017
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@BridgeAR

BridgeAR commented May 11, 2018

Copy link
Copy Markdown
Member

Landed in f145a53...5096e24.

I changed the test title as agreed upon with @addaleax

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR closed this May 11, 2018
targos pushed a commit that referenced this pull request May 12, 2018
@addaleax @targos
test: make sure linked lists are inspectable with defaults
de34cfa
Make sure that a long singly-linked list can be passed
to `util.inspect()` without causing a stack overflow.

PR-URL: #20017
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@addaleax addaleax mentioned this pull request May 14, 2018
v10.2.0 proposal #20724
Merged
@inoway46 inoway46 mentioned this pull request Aug 16, 2026
test: format errors with configurable (or hardcoded infinite) depth #65266
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Trott Trott Trott approved these changes
@cjihrig cjihrig cjihrig approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
@BridgeAR BridgeAR Awaiting requested review from BridgeAR
+1 more reviewer
@TimothyGu TimothyGu TimothyGu approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

repl Issues and PRs related to the REPL subsystem. util Issues and PRs related to the built-in util module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@addaleax @jasnell @Trott @mcollina @apapirovski @BridgeAR @cjihrig @TimothyGu @joyeecheung @nodejs-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.