Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fixing isStackOverflowError to account for different JS engines #19705

Closed
Changes from 2 commits
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
11 changes: 7 additions & 4 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ function dnsException(err, syscall, hostname) {
return ex;
}

let MAX_STACK_MESSAGE;
let MAX_STACK_ERROR_NAME;
let MAX_STACK_ERROR_MESSAGE;
/**
* Returns true if `err` is a `RangeError` with an engine-specific message.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment needs to be updated as well.

* "Maximum call stack size exceeded" in V8.
Expand All @@ -581,16 +582,18 @@ let MAX_STACK_MESSAGE;
* @returns {boolean}
*/
function isStackOverflowError(err) {
if (MAX_STACK_MESSAGE === undefined) {
if (MAX_STACK_ERROR_MESSAGE === undefined) {
try {
function overflowStack() { overflowStack(); }
overflowStack();
} catch (err) {
MAX_STACK_MESSAGE = err.message;
MAX_STACK_ERROR_MESSAGE = err.message;
MAX_STACK_ERROR_NAME = err.name;
}
}

return err.name === 'RangeError' && err.message === MAX_STACK_MESSAGE;
return err.name === MAX_STACK_ERROR_NAME &&
err.message === MAX_STACK_ERROR_MESSAGE;
}

module.exports = exports = {
Expand Down