Skip to content

Commit

Permalink
util: fix crashing when emitting new Buffer() deprecation warning #53075
Browse files Browse the repository at this point in the history


PR-URL: #53089
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
Uzlopak authored and aduh95 committed Jul 12, 2024
1 parent 073aa7f commit f05521b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const {
SafeWeakRef,
StringPrototypeIncludes,
StringPrototypeReplace,
StringPrototypeStartsWith,
StringPrototypeToLowerCase,
StringPrototypeToUpperCase,
Symbol,
Expand Down Expand Up @@ -515,11 +516,14 @@ function isInsideNodeModules() {
if (ArrayIsArray(stack)) {
for (const frame of stack) {
const filename = frame.getFileName();
// If a filename does not start with / or contain \,
// it's likely from Node.js core.

if (
filename[0] !== '/' &&
StringPrototypeIncludes(filename, '\\') === false
filename == null ||
StringPrototypeStartsWith(filename, 'node:') === true ||
(
filename[0] !== '/' &&
StringPrototypeIncludes(filename, '\\') === false
)
) {
continue;
}
Expand Down

0 comments on commit f05521b

Please sign in to comment.