From 096e44a8a9dd20e3159ee15bc2563c6a58dc344f 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 e9345d56609e0a..e8763d204ee348 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -37,6 +37,7 @@ const { SafeWeakRef, StringPrototypeIncludes, StringPrototypeReplace, + StringPrototypeStartsWith, StringPrototypeToLowerCase, StringPrototypeToUpperCase, Symbol, @@ -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; }