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 marco-ippolito committed Aug 19, 2024
1 parent 0c24b91 commit ce877c6
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 @@ -502,11 +503,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 ce877c6

Please sign in to comment.