From ce877c6d0fb0cafd4cecf2a1d4655b6fe241840f Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Thu, 11 Jul 2024 14:13:20 +0200 Subject: [PATCH] util: fix crashing when emitting new Buffer() deprecation warning #53075 PR-URL: https://github.com/nodejs/node/pull/53089 Reviewed-By: James M Snell Reviewed-By: Yagiz Nizipli Reviewed-By: Tim Perry Reviewed-By: Matteo Collina --- lib/internal/util.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/internal/util.js b/lib/internal/util.js index 666ae78a0e957c..de3e3d56195bae 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -37,6 +37,7 @@ const { SafeWeakRef, StringPrototypeIncludes, StringPrototypeReplace, + StringPrototypeStartsWith, StringPrototypeToLowerCase, StringPrototypeToUpperCase, Symbol, @@ -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; }