lib: fix stack overflow check to not break on primitives

PR-URL: https://github.com/nodejs/node/pull/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>
pull/28504/head
kball 2019-06-21 15:08:38 -05:00 committed by Anna Henningsen
parent 367ada49f1
commit 85496e94d3
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
2 changed files with 15 additions and 1 deletions

View File

@ -587,7 +587,7 @@ function isStackOverflowError(err) {
}
}
return err.name === maxStack_ErrorName &&
return err && err.name === maxStack_ErrorName &&
err.message === maxStack_ErrorMessage;
}

View File

@ -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