Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add regression test for inspect depth
Make sure that a long singly-linked list can be passed
to `util.inspect()` without causing a stack overflow.
  • Loading branch information
addaleax authored and BridgeAR committed May 9, 2018
commit eec6468cfe428744f169b17149fb3ce05d3c2763
12 changes: 12 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,3 +1404,15 @@ util.inspect(process);
const args = (function() { return arguments; })('a');
assert.strictEqual(util.inspect(args), "[Arguments] { '0': 'a' }");
}

{
// Test that a long linked list can be inspected without throwing an error.
const list = {};
let head = list;
// The real cutoff value is closer to 1400 stack frames as of May 2018,
// but let's be generous here – even a linked listed of length 100k should be
// inspectable in some way.
for (let i = 0; i < 100000; i++)
head = head.next = {};
util.inspect(list);
}