Skip to content

Commit

Permalink
lib: fix stack overflow check to not break on primitives
Browse files Browse the repository at this point in the history
PR-URL: #28338
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
kball authored and targos committed Jul 2, 2019
1 parent 937afcc commit 5f9ee9f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ function isStackOverflowError(err) {
}
}

return err.name === maxStack_ErrorName &&
return err && err.name === maxStack_ErrorName &&
err.message === maxStack_ErrorMessage;
}

Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-console-log-throw-primitive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
require('../common');
const { Writable } = require('stream');
const { Console } = require('console');

const stream = new Writable({
write() {
throw null; // eslint-disable-line no-throw-literal
}
});

const console = new Console({ stdout: stream });

console.log('test'); // Should not throw

0 comments on commit 5f9ee9f

Please sign in to comment.