Skip to content

Commit

Permalink
util: use assert for unreachable code
Browse files Browse the repository at this point in the history
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.

PR-URL: #37249
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
Trott authored and danielleadams committed Feb 16, 2021
1 parent ebf3597 commit 7c51cec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,8 @@ function handleMaxCallStackSize(ctx, err, constructorName, indentationLvl) {
'special'
);
}
throw err;
/* c8 ignore next */
assert.fail(err.stack);
}

function formatNumber(fn, value) {
Expand Down

0 comments on commit 7c51cec

Please sign in to comment.