-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: fix isInsideNodeModules inside error
When isInsideNodeModules gets called while already processing another stack trace, V8 will not call prepareStackTrace again. This used to cause Node.js to just crash — fix it by checking for expected return type of the stack (Array). PR-URL: #20266 Fixes: #20258 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
- Loading branch information
1 parent
29bc735
commit 3962c73
Showing
2 changed files
with
27 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
test/parallel/test-buffer-constructor-deprecation-error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const bufferWarning = 'Buffer() is deprecated due to security and usability ' + | ||
'issues. Please use the Buffer.alloc(), ' + | ||
'Buffer.allocUnsafe(), or Buffer.from() methods instead.'; | ||
|
||
common.expectWarning('DeprecationWarning', bufferWarning, 'DEP0005'); | ||
|
||
// This is used to make sure that a warning is only emitted once even though | ||
// `new Buffer()` is called twice. | ||
process.on('warning', common.mustCall()); | ||
|
||
Error.prepareStackTrace = (err, trace) => new Buffer(10); | ||
|
||
new Error().stack; |