Skip to content

Commit 5f9ee9f

Browse files
kballtargos
authored andcommitted
lib: fix stack overflow check to not break on primitives
PR-URL: #28338 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 937afcc commit 5f9ee9f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ function isStackOverflowError(err) {
582582
}
583583
}
584584

585-
return err.name === maxStack_ErrorName &&
585+
return err && err.name === maxStack_ErrorName &&
586586
err.message === maxStack_ErrorMessage;
587587
}
588588

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
require('../common');
3+
const { Writable } = require('stream');
4+
const { Console } = require('console');
5+
6+
const stream = new Writable({
7+
write() {
8+
throw null; // eslint-disable-line no-throw-literal
9+
}
10+
});
11+
12+
const console = new Console({ stdout: stream });
13+
14+
console.log('test'); // Should not throw

0 commit comments

Comments
 (0)