GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — util: change inspect depth default by BridgeAR · Pull Request #17907 · nodejs/node Conversation
Member
Right now the defaults for Refs: #12693 Checklist
Affected core subsystem(s)util, console
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
lpinca
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for not using
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type check has to be done again in that case.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubt it will add a noticeable overhead but yes it makes sense.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the use _extend as it will still be faster than Object.assign
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About the performance - just recently I heard that
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
@silverwind I do not see a big difference between 5 and unlimited. Most entries are not that deeply nested and if they are, you likely want to see everything. To prevent huge diffs, the max array entries option is way more efficient as this would otherwise be more difficult to handle. About the complexity: I am fine with showing everything as a new default for console.* and this would remove the complexity again. But it would be a more significant change and I tried to minimize the breaking change. For the repl it might be best to stay with the current default though. The reason is that some modules like |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jasnell what do you think about removing the limit for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Changing the default for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Currently inspecting the BufferList can result a maximum call stack size error. Adding a individual inspect function prevents this.
The current default is not ideal in most use cases. Therefore it is changed to showing unlimited depth in case util.inspect is called directly. The default is kept as before for console.log and similar. Using console.dir will now show a depth of up to five and console.assert / console.trace will show a unlimited depth.
Object.assign is currently very slow. Using Object.keys is much faster in v8 6.3.
2bb38d6 to
2721767
Compare
|
I changed the code to default to unlimited for the console functions as well. CITGM https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1179/ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| [customInspectSymbol]() { | ||
| return `${this.constructor.name} { length: ${this.length} }`; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You could return { __proto__: Object.getPrototypeOf(this), length: this.length } which would also give coloring etc. for free.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Using __proto__ will actually result in a `call stack size exceeded error. I decided to call inspect directly instead to highlight the color in case it is needed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
New CI https://ci.nodejs.org/job/node-test-pull-request/12363/ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you please change the documentation of util.inspect (and add an entry to its history)?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return ret; | ||
| } | ||
|
|
||
| [customInspectSymbol]() { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I’d just use util.inspect.custom here, it saves people looking at this code one round-trip to another file
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Since the default for depth is changed to `Infinity` it is logical to change the %o default to the same as well. Using %o with `util.format` will now always print the whole object.
|
I updated the documentation and added the history entry. I also changed the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * `depth` {number} Specifies the number visible nested Objects in an `object`. | ||
| This is useful to minimize the inspection output for large complicated | ||
| objects. To make it recurse indefinitely pass `null` or `Infinity`. Defaults | ||
| to `null`. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Infinity instead of null to match the changelog?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The current default is not ideal in most use cases. Therefore it is changed to inspect objects to a maximum depth of 20 in case util.inspect is called with it's defaults. The default is kept at 2 when using console.log() and similar in the repl. PR-URL: nodejs#17907 Refs: nodejs#12693
Since the default for depth is changed to `20` it is logical to change the %o default as well. It will now always use the default depth. PR-URL: nodejs#17907 Refs: nodejs#12693
The current default is not ideal in most use cases. Therefore it is changed to inspect objects to a maximum depth of 20 in case util.inspect is called with it's defaults. The default is kept at 2 when using console.log() and similar in the repl. PR-URL: nodejs#17907 Refs: nodejs#12693 PR-URL: nodejs#22846 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
Since the default for depth is changed to `20` it is logical to change the %o default as well. It will now always use the default depth. PR-URL: nodejs#17907 Refs: nodejs#12693 PR-URL: nodejs#22846 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.