summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-05-14 19:50:45 +0200
committerAnatoli Papirovski <apapirovski@mac.com>2018-06-24 23:11:52 -0700
commitb26506b95f7c9322710a884213ee61f27c28eeec (patch)
treee3a2fdda33eb6da62401b964d8c0a804430c7f0d /test
parent43a20911873e64b841de3ff1f9a66a6230bcc7c6 (diff)
downloadandroid-node-v8-b26506b95f7c9322710a884213ee61f27c28eeec.tar.gz
android-node-v8-b26506b95f7c9322710a884213ee61f27c28eeec.tar.bz2
android-node-v8-b26506b95f7c9322710a884213ee61f27c28eeec.zip
util: recover from maximum call stack size
Using util.inspect should still return values in case the maximum call stack size is reached. This is important to inspect linked lists and similar. PR-URL: https://github.com/nodejs/node/pull/20725 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-util-inspect.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 347f5046a8..1f05f4987e 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -1410,10 +1410,17 @@ util.inspect(process);
// 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.
+ // A linked list of length 100k should be inspectable in some way, even though
+ // the real cutoff value is much lower than 100k.
for (let i = 0; i < 100000; i++)
head = head.next = {};
- util.inspect(list);
+ assert.strictEqual(
+ util.inspect(list),
+ '{ next: { next: { next: [Object] } } }'
+ );
+ const longList = util.inspect(list, { depth: Infinity });
+ const match = longList.match(/next/g);
+ assert(match.length > 1000 && match.length < 10000);
+ assert(longList.includes('[Object: Inspection interrupted ' +
+ 'prematurely. Maximum call stack size exceeded.]'));
}