From f888d2a2147d46bb9721ce8c89c23197b5838e48 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 6 Feb 2021 08:03:04 -0800 Subject: [PATCH] util: use assert for unreachable code Great effort is taken to keep `util.inspect()` from throwing while inspecting a linked list or other items that require recursion. It is likely still possible at this time to cause a throw with prototype pollution, but that will change soon when the code is modified to use primordials. This commit instructs our coverage to not be concerned about not being able to reach the throwing-an-error code and changes the throw there to an assert so users will be instructed to open a bug with Node.js should they manage to cause the code to throw. --- lib/internal/util/inspect.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 88e70647626c6c..0bdb1128f08e50 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1360,7 +1360,8 @@ function handleMaxCallStackSize(ctx, err, constructorName, indentationLvl) { 'special' ); } - throw err; + /* c8 ignore next */ + assert.fail(err.stack); } function formatNumber(fn, value) {