From b175a73139ae1570dfdac6c899ce0e16e8840974 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Tue, 21 May 2024 23:17:10 +0200 Subject: [PATCH] util: fix WASM crashes on Node v22.2.0 if it reaches the new Buffer() deprecation warning #53075 --- 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 25bb82afea8ee5..de8cff105593f4 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; }