Browse Source

chore: bump node to v22.13.1 (35-x-y) (#45216)

* chore: bump node in DEPS to v22.13.0

* chore: bump node in DEPS to v22.13.1

* src: move evp stuff to ncrypto

https://github.com/nodejs/node/pull/54911

* crypto: add Date fields for validTo and validFrom

https://github.com/nodejs/node/pull/54159

* module: fix discrepancy between .ts and .js

https://github.com/nodejs/node/pull/54461

* esm: do not interpret "main" as a URL

https://github.com/nodejs/node/pull/55003

* src: modernize likely/unlikely hints

https://github.com/nodejs/node/pull/55155

* chore: update patch indices

* crypto: add validFromDate and validToDate fields to X509Certificate

https://github.com/nodejs/node/pull/54159

* chore: fixup perfetto patch

* fix: clang warning in simdjson

* src: add receiver to fast api callback methods

https://github.com/nodejs/node/pull/54408

* chore: fixup revert patch

* fixup! esm: do not interpret "main" as a URL

* fixup! crypto: add Date fields for validTo and validFrom

* fix: move ArrayBuffer test patch

* src: fixup Error.stackTraceLimit during snapshot building

https://github.com/nodejs/node/pull/55121

* fix: bad rebase

* chore: fixup amaro

* chore: address feedback from review

* src: revert filesystem::path changes

https://github.com/nodejs/node/pull/55015

* chore: fixup GN build file

* https://github.com/nodejs/node/pull/55529
* https://github.com/nodejs/node/pull/55798
* https://github.com/nodejs/node/pull/55530

* module: simplify --inspect-brk handling

https://github.com/nodejs/node/pull/55679

* src: fix outdated js2c.cc references

https://github.com/nodejs/node/pull/56133

* crypto: include openssl/rand.h explicitly

https://github.com/nodejs/node/pull/55425

* build: use variable for crypto dep path

https://github.com/nodejs/node/pull/55928

* crypto: fix RSA_PKCS1_PADDING error message

https://github.com/nodejs/node/pull/55629

* build: use variable for simdutf path

https://github.com/nodejs/node/pull/56196

* test,crypto: make crypto tests work with BoringSSL

https://github.com/nodejs/node/pull/55491

* fix: suppress clang -Wdeprecated-declarations in libuv

https://github.com/libuv/libuv/pull/4486

* deps: update libuv to 1.49.1

https://github.com/nodejs/node/pull/55114

* test: make test-node-output-v8-warning more flexible

https://github.com/nodejs/node/pull/55401

* [v22.x] Revert "v8: enable maglev on supported architectures"

https://github.com/nodejs/node/pull/54384

* fix: potential WIN32_LEAN_AND_MEAN redefinition

https://github.com/c-ares/c-ares/pull/869

* deps: update nghttp2 to 1.64.0

https://github.com/nodejs/node/pull/55559

* src: provide workaround for container-overflow

https://github.com/nodejs/node/pull/55591

* build: use variable for simdutf path

https://github.com/nodejs/node/pull/56196

* chore: fixup patch indices

* fixup! module: simplify --inspect-brk handling

* lib: fix fs.readdir recursive async

https://github.com/nodejs/node/pull/56041

* lib: avoid excluding symlinks in recursive fs.readdir with filetypes

https://github.com/nodejs/node/pull/55714/

This doesn't currently play well with ASAR - this should be fixed in a follow up

* test: disable CJS permission test for config.main

This has diverged as a result of our revert of
src,lb: reducing C++ calls of esm legacy main resolve

* fixup! lib: fix fs.readdir recursive async

* deps: update libuv to 1.49.1

https://github.com/nodejs/node/pull/55114

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
electron-roller[bot] 2 months ago
parent
commit
bc163a5ea8
42 changed files with 660 additions and 1245 deletions
  1. 1 1
      DEPS
  2. 163 56
      lib/node/asar-fs-wrapper.ts
  3. 1 6
      patches/node/.patches
  4. 54 71
      patches/node/build_add_gn_build_files.patch
  5. 4 21
      patches/node/build_allow_unbundling_of_node_js_dependencies.patch
  6. 1 1
      patches/node/build_compile_with_c_20_support.patch
  7. 0 36
      patches/node/build_don_t_redefine_win32_lean_and_mean.patch
  8. 19 33
      patches/node/build_enable_perfetto.patch
  9. 4 4
      patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch
  10. 4 4
      patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch
  11. 1 1
      patches/node/build_restore_clang_as_default_compiler_on_macos.patch
  12. 6 37
      patches/node/build_use_third_party_simdutf.patch
  13. 18 18
      patches/node/chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch
  14. 5 5
      patches/node/chore_disable_deprecation_ftbfs_in_simdjson_header.patch
  15. 6 6
      patches/node/chore_expose_importmoduledynamically_and.patch
  16. 6 6
      patches/node/cli_remove_deprecated_v8_flag.patch
  17. 3 3
      patches/node/enable_crashpad_linux_node_processes.patch
  18. 23 29
      patches/node/feat_add_uv_loop_interrupt_on_io_change_option_to_uv_loop_configure.patch
  19. 0 60
      patches/node/fix_-wextra-semi_errors_in_nghttp2_helper_h.patch
  20. 1 1
      patches/node/fix_add_default_values_for_variables_in_common_gypi.patch
  21. 4 4
      patches/node/fix_assert_module_in_the_renderer_process.patch
  22. 51 157
      patches/node/fix_crypto_tests_to_run_with_bssl.patch
  23. 6 6
      patches/node/fix_do_not_resolve_electron_entrypoints.patch
  24. 13 13
      patches/node/fix_expose_the_built-in_electron_module_via_the_esm_loader.patch
  25. 71 83
      patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch
  26. 13 13
      patches/node/fix_lazyload_fs_in_esm_loaders_to_apply_asar_patches.patch
  27. 1 1
      patches/node/fix_remove_deprecated_errno_constants.patch
  28. 14 15
      patches/node/fix_remove_fastapitypedarray_usage.patch
  29. 2 2
      patches/node/fix_remove_harmony-import-assertions_from_node_cc.patch
  30. 41 294
      patches/node/fix_revert_src_lb_reducing_c_calls_of_esm_legacy_main_resolve.patch
  31. 0 29
      patches/node/fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch
  32. 51 0
      patches/node/linux_try_preadv64_pwritev64_before_preadv_pwritev_4683.patch
  33. 10 10
      patches/node/pass_all_globals_through_require.patch
  34. 1 1
      patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch
  35. 0 45
      patches/node/src_provide_workaround_for_container-overflow.patch
  36. 9 9
      patches/node/src_remove_dependency_on_wrapper-descriptor-based_cppheap.patch
  37. 17 26
      patches/node/src_stop_using_deprecated_fields_of_fastapicallbackoptions.patch
  38. 30 15
      patches/node/support_v8_sandboxed_pointers.patch
  39. 2 2
      patches/node/test_formally_mark_some_tests_as_flaky.patch
  40. 0 51
      patches/node/test_make_test-node-output-v8-warning_generic.patch
  41. 0 70
      patches/node/win_almost_fix_race_detecting_esrch_in_uv_kill.patch
  42. 4 0
      script/node-disabled-tests.json

+ 1 - 1
DEPS

@@ -4,7 +4,7 @@ vars = {
   'chromium_version':
     '134.0.6990.0',
   'node_version':
-    'v22.9.0',
+    'v22.13.1',
   'nan_version':
     'e14bdcd1f72d62bca1d541b66da43130384ec213',
   'squirrel.mac_version':

+ 163 - 56
lib/node/asar-fs-wrapper.ts

@@ -24,6 +24,8 @@ const nextTick = (functionToCall: Function, args: any[] = []) => {
   process.nextTick(() => functionToCall(...args));
 };
 
+const binding = internalBinding('fs');
+
 // Cache asar archive objects.
 const cachedArchives = new Map<string, NodeJS.AsarArchive>();
 
@@ -705,7 +707,137 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
   };
 
   type ReaddirOptions = { encoding: BufferEncoding | null; withFileTypes?: false, recursive?: false } | undefined | null;
-  type ReaddirCallback = (err: NodeJS.ErrnoException | null, files: string[]) => void;
+  type ReaddirCallback = (err: NodeJS.ErrnoException | null, files?: string[]) => void;
+
+  const processReaddirResult = (args: any) => (args.context.withFileTypes ? handleDirents(args) : handleFilePaths(args));
+
+  function handleDirents ({ result, currentPath, context }: { result: any[], currentPath: string, context: any }) {
+    const length = result[0].length;
+    for (let i = 0; i < length; i++) {
+      const resultPath = path.join(currentPath, result[0][i]);
+      const info = splitPath(resultPath);
+
+      let type = result[1][i];
+      if (info.isAsar) {
+        const archive = getOrCreateArchive(info.asarPath);
+        if (!archive) return;
+        const stats = archive.stat(info.filePath);
+        if (!stats) continue;
+        type = stats.type;
+      }
+
+      const dirent = getDirent(currentPath, result[0][i], type);
+      const stat = internalBinding('fs').internalModuleStat(binding, resultPath);
+
+      context.readdirResults.push(dirent);
+      if (dirent.isDirectory() || stat === 1) {
+        context.pathsQueue.push(path.join(dirent.path, dirent.name));
+      }
+    }
+  }
+
+  function handleFilePaths ({ result, currentPath, context }: { result: string[], currentPath: string, context: any }) {
+    for (let i = 0; i < result.length; i++) {
+      const resultPath = path.join(currentPath, result[i]);
+      const relativeResultPath = path.relative(context.basePath, resultPath);
+      const stat = internalBinding('fs').internalModuleStat(binding, resultPath);
+      context.readdirResults.push(relativeResultPath);
+
+      if (stat === 1) {
+        context.pathsQueue.push(resultPath);
+      }
+    }
+  }
+
+  function readdirRecursive (basePath: string, options: ReaddirOptions, callback: ReaddirCallback) {
+    const context = {
+      withFileTypes: Boolean(options!.withFileTypes),
+      encoding: options!.encoding,
+      basePath,
+      readdirResults: [],
+      pathsQueue: [basePath]
+    };
+
+    let i = 0;
+
+    function read (pathArg: string) {
+      const req = new binding.FSReqCallback();
+      req.oncomplete = (err: any, result: string) => {
+        if (err) {
+          callback(err);
+          return;
+        }
+
+        if (result === undefined) {
+          callback(null, context.readdirResults);
+          return;
+        }
+
+        processReaddirResult({
+          result,
+          currentPath: pathArg,
+          context
+        });
+
+        if (i < context.pathsQueue.length) {
+          read(context.pathsQueue[i++]);
+        } else {
+          callback(null, context.readdirResults);
+        }
+      };
+
+      const pathInfo = splitPath(pathArg);
+      if (pathInfo.isAsar) {
+        let readdirResult;
+        const { asarPath, filePath } = pathInfo;
+
+        const archive = getOrCreateArchive(asarPath);
+        if (!archive) {
+          const error = createError(AsarError.INVALID_ARCHIVE, { asarPath });
+          nextTick(callback, [error]);
+          return;
+        }
+
+        readdirResult = archive.readdir(filePath);
+        if (!readdirResult) {
+          const error = createError(AsarError.NOT_FOUND, { asarPath, filePath });
+          nextTick(callback, [error]);
+          return;
+        }
+
+        // If we're in an asar dir, we need to ensure the result is in the same format as the
+        // native call to readdir withFileTypes i.e. an array of arrays.
+        if (context.withFileTypes) {
+          readdirResult = [
+            [...readdirResult], readdirResult.map((p: string) => {
+              return internalBinding('fs').internalModuleStat(binding, path.join(pathArg, p));
+            })
+          ];
+        }
+
+        processReaddirResult({
+          result: readdirResult,
+          currentPath: pathArg,
+          context
+        });
+
+        if (i < context.pathsQueue.length) {
+          read(context.pathsQueue[i++]);
+        } else {
+          callback(null, context.readdirResults);
+        }
+      } else {
+        binding.readdir(
+          pathArg,
+          context.encoding,
+          context.withFileTypes,
+          req
+        );
+      }
+    }
+
+    read(context.pathsQueue[i++]);
+  }
 
   const { readdir } = fs;
   fs.readdir = function (pathArgument: string, options: ReaddirOptions, callback: ReaddirCallback) {
@@ -720,7 +852,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
     }
 
     if (options?.recursive) {
-      nextTick(callback!, [null, readdirSyncRecursive(pathArgument, options)]);
+      readdirRecursive(pathArgument, options, callback);
       return;
     }
 
@@ -771,7 +903,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
     }
 
     if (options?.recursive) {
-      return readdirRecursive(pathArgument, options);
+      return readdirRecursivePromises(pathArgument, options);
     }
 
     const pathInfo = splitPath(pathArgument);
@@ -868,12 +1000,10 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
     return readPackageJSON(realPath, isESM, base, specifier);
   };
 
-  const binding = internalBinding('fs');
-
   const { internalModuleStat } = binding;
-  internalBinding('fs').internalModuleStat = (pathArgument: string) => {
+  internalBinding('fs').internalModuleStat = (receiver: unknown, pathArgument: string) => {
     const pathInfo = splitPath(pathArgument);
-    if (!pathInfo.isAsar) return internalModuleStat(pathArgument);
+    if (!pathInfo.isAsar) return internalModuleStat(receiver, pathArgument);
     const { asarPath, filePath } = pathInfo;
 
     // -ENOENT
@@ -888,7 +1018,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
   };
 
   const { kUsePromises } = binding;
-  async function readdirRecursive (originalPath: string, options: ReaddirOptions) {
+  async function readdirRecursivePromises (originalPath: string, options: ReaddirOptions) {
     const result: any[] = [];
 
     const pathInfo = splitPath(originalPath);
@@ -908,7 +1038,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
       if (withFileTypes) {
         initialItem = [
           [...initialItem], initialItem.map((p: string) => {
-            return internalBinding('fs').internalModuleStat(path.join(originalPath, p));
+            return internalBinding('fs').internalModuleStat(binding, path.join(originalPath, p));
           })
         ];
       }
@@ -941,7 +1071,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
 
               readdirResult = [
                 [...files], files.map((p: string) => {
-                  return internalBinding('fs').internalModuleStat(path.join(direntPath, p));
+                  return internalBinding('fs').internalModuleStat(binding, path.join(direntPath, p));
                 })
               ];
             } else {
@@ -962,7 +1092,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
         const { 0: pathArg, 1: readDir } = queue.pop();
         for (const ent of readDir) {
           const direntPath = path.join(pathArg, ent);
-          const stat = internalBinding('fs').internalModuleStat(direntPath);
+          const stat = internalBinding('fs').internalModuleStat(binding, direntPath);
           result.push(path.relative(originalPath, direntPath));
 
           if (stat === 1) {
@@ -992,11 +1122,13 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
   }
 
   function readdirSyncRecursive (basePath: string, options: ReaddirOptions) {
-    const withFileTypes = Boolean(options!.withFileTypes);
-    const encoding = options!.encoding;
-
-    const readdirResults: string[] = [];
-    const pathsQueue = [basePath];
+    const context = {
+      withFileTypes: Boolean(options!.withFileTypes),
+      encoding: options!.encoding,
+      basePath,
+      readdirResults: [] as any,
+      pathsQueue: [basePath]
+    };
 
     function read (pathArg: string) {
       let readdirResult;
@@ -1011,62 +1143,37 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
         if (!readdirResult) return;
         // If we're in an asar dir, we need to ensure the result is in the same format as the
         // native call to readdir withFileTypes i.e. an array of arrays.
-        if (withFileTypes) {
+        if (context.withFileTypes) {
           readdirResult = [
             [...readdirResult], readdirResult.map((p: string) => {
-              return internalBinding('fs').internalModuleStat(path.join(pathArg, p));
+              return internalBinding('fs').internalModuleStat(binding, path.join(pathArg, p));
             })
           ];
         }
       } else {
         readdirResult = binding.readdir(
           path.toNamespacedPath(pathArg),
-          encoding,
-          withFileTypes
+          context.encoding,
+          context.withFileTypes
         );
       }
 
-      if (readdirResult === undefined) return;
-
-      if (withFileTypes) {
-        const length = readdirResult[0].length;
-        for (let i = 0; i < length; i++) {
-          const resultPath = path.join(pathArg, readdirResult[0][i]);
-          const info = splitPath(resultPath);
-
-          let type = readdirResult[1][i];
-          if (info.isAsar) {
-            const archive = getOrCreateArchive(info.asarPath);
-            if (!archive) return;
-            const stats = archive.stat(info.filePath);
-            if (!stats) continue;
-            type = stats.type;
-          }
-
-          const dirent = getDirent(pathArg, readdirResult[0][i], type);
-
-          readdirResults.push(dirent);
-          if (dirent.isDirectory()) {
-            pathsQueue.push(path.join(dirent.path, dirent.name));
-          }
-        }
-      } else {
-        for (let i = 0; i < readdirResult.length; i++) {
-          const resultPath = path.join(pathArg, readdirResult[i]);
-          const relativeResultPath = path.relative(basePath, resultPath);
-          const stat = internalBinding('fs').internalModuleStat(resultPath);
-
-          readdirResults.push(relativeResultPath);
-          if (stat === 1) pathsQueue.push(resultPath);
-        }
+      if (readdirResult === undefined) {
+        return;
       }
+
+      processReaddirResult({
+        result: readdirResult,
+        currentPath: pathArg,
+        context
+      });
     }
 
-    for (let i = 0; i < pathsQueue.length; i++) {
-      read(pathsQueue[i]);
+    for (let i = 0; i < context.pathsQueue.length; i++) {
+      read(context.pathsQueue[i]);
     }
 
-    return readdirResults;
+    return context.readdirResults;
   }
 
   // Calling mkdir for directory inside asar archive should throw ENOTDIR

+ 1 - 6
patches/node/.patches

@@ -9,7 +9,6 @@ fix_handle_boringssl_and_openssl_incompatibilities.patch
 fix_crypto_tests_to_run_with_bssl.patch
 fix_account_for_debugger_agent_race_condition.patch
 fix_readbarrier_undefined_symbol_error_on_woa_arm64.patch
-fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch
 feat_add_uv_loop_interrupt_on_io_change_option_to_uv_loop_configure.patch
 support_v8_sandboxed_pointers.patch
 build_ensure_native_module_compilation_fails_if_not_using_a_new.patch
@@ -21,7 +20,6 @@ test_formally_mark_some_tests_as_flaky.patch
 fix_do_not_resolve_electron_entrypoints.patch
 ci_ensure_node_tests_set_electron_run_as_node.patch
 fix_assert_module_in_the_renderer_process.patch
-test_make_test-node-output-v8-warning_generic.patch
 fix_revert_src_lb_reducing_c_calls_of_esm_legacy_main_resolve.patch
 fix_remove_deprecated_errno_constants.patch
 build_enable_perfetto.patch
@@ -30,18 +28,15 @@ src_remove_dependency_on_wrapper-descriptor-based_cppheap.patch
 test_update_v8-stats_test_for_v8_12_6.patch
 src_do_not_use_soon-to-be-deprecated_v8_api.patch
 src_stop_using_deprecated_fields_of_fastapicallbackoptions.patch
-build_don_t_redefine_win32_lean_and_mean.patch
 build_compile_with_c_20_support.patch
 add_v8_taskpirority_to_foreground_task_runner_signature.patch
 cli_remove_deprecated_v8_flag.patch
 build_restore_clang_as_default_compiler_on_macos.patch
-fix_-wextra-semi_errors_in_nghttp2_helper_h.patch
 fix_remove_harmony-import-assertions_from_node_cc.patch
-win_almost_fix_race_detecting_esrch_in_uv_kill.patch
 chore_disable_deprecation_ftbfs_in_simdjson_header.patch
-src_provide_workaround_for_container-overflow.patch
 build_allow_unbundling_of_node_js_dependencies.patch
 test_use_static_method_names_in_call_stacks.patch
 build_use_third_party_simdutf.patch
 fix_remove_fastapitypedarray_usage.patch
 test_handle_explicit_resource_management_globals.patch
+linux_try_preadv64_pwritev64_before_preadv_pwritev_4683.patch

+ 54 - 71
patches/node/build_add_gn_build_files.patch

@@ -10,28 +10,19 @@ however those files were cherry-picked from main branch and do not
 really in 20/21. We have to wait until 22 is released to be able to
 build with upstream GN files.
 
-diff --git a/deps/sqlite/unofficial.gni b/deps/sqlite/unofficial.gni
-index ebb3ffcd6d42b4c16b6865a91ccf4428cffe864b..00225afa1fb4205f1e02d9f185aeb97d642b3fd9 100644
---- a/deps/sqlite/unofficial.gni
-+++ b/deps/sqlite/unofficial.gni
-@@ -18,8 +18,14 @@ template("sqlite_gn_build") {
+diff --git a/deps/simdjson/unofficial.gni b/deps/simdjson/unofficial.gni
+index d6909b95886f4de3f0b953c2a2992f69066b7434..972955f9144aafcd3a3fe278b7aaad401cadddda 100644
+--- a/deps/simdjson/unofficial.gni
++++ b/deps/simdjson/unofficial.gni
+@@ -18,5 +18,6 @@ template("simdjson_gn_build") {
      forward_variables_from(invoker, "*")
-     public_configs = [ ":sqlite_config" ]
-     sources = gypi_values.sqlite_sources
-+    cflags_c = [
-+      "-Wno-implicit-fallthrough",
-+      "-Wno-unreachable-code-break",
-+      "-Wno-unreachable-code-return",
-+      "-Wno-unreachable-code",
-+    ]
-     if (is_win) {
--      cflags_c = [
-+      cflags_c += [
-         "-Wno-sign-compare",
-         "-Wno-unused-but-set-variable",
-         "-Wno-unused-function",
+     public_configs = [ ":simdjson_config" ]
+     sources = gypi_values.simdjson_sources
++    cflags_c = [ "-Wdeprecated-literal-operator" ]
+   }
+ }
 diff --git a/node.gni b/node.gni
-index 9dca810decebd75aab427e306b3cc37c80fb55c9..32709b860ccb12d8d1e75342a65dda0b86129b21 100644
+index a2123cc6c6d21c53fafc8934203b3720393e7b11..245a43920c7baf000ba63192a84a4c3fd219be7d 100644
 --- a/node.gni
 +++ b/node.gni
 @@ -5,10 +5,10 @@
@@ -41,13 +32,13 @@ index 9dca810decebd75aab427e306b3cc37c80fb55c9..32709b860ccb12d8d1e75342a65dda0b
 -  node_path = "//node"
 +  node_path = "//third_party/electron_node"
  
-   # The location of V8, use the one from node's deps by default.
+   # The location of V8 - use the one from node's deps by default.
 -  node_v8_path = "$node_path/deps/v8"
 +  node_v8_path = "//v8"
  
-   # The NODE_MODULE_VERSION defined in node_version.h.
-   node_module_version = exec_script("$node_path/tools/getmoduleversion.py", [], "value")
-@@ -38,7 +38,7 @@ declare_args() {
+   # The location of OpenSSL - use the one from node's deps by default.
+   node_openssl_path = "$node_path/deps/openssl"
+@@ -44,7 +44,7 @@ declare_args() {
    node_openssl_system_ca_path = ""
  
    # Initialize v8 platform during node.js startup.
@@ -56,20 +47,29 @@ index 9dca810decebd75aab427e306b3cc37c80fb55c9..32709b860ccb12d8d1e75342a65dda0b
  
    # Custom build tag.
    node_tag = ""
-@@ -58,7 +58,7 @@ declare_args() {
+@@ -64,10 +64,16 @@ declare_args() {
    # TODO(zcbenz): There are few broken things for now:
    #   1. cross-os compilation is not supported.
    #   2. node_mksnapshot crashes when cross-compiling for x64 from arm64.
 -  node_use_node_snapshot = (host_os == target_os) && !(host_cpu == "arm64" && target_cpu == "x64")
 +  node_use_node_snapshot = false
+ 
+   # Build with Amaro (TypeScript utils).
+   node_use_amaro = true
++
++  # Allows downstream packagers (eg. Linux distributions) to build against system shared libraries.
++  use_system_cares = false
++  use_system_nghttp2 = false
++  use_system_llhttp = false
++  use_system_histogram = false
  }
  
  assert(!node_enable_inspector || node_use_openssl,
 diff --git a/src/node_builtins.cc b/src/node_builtins.cc
-index 2bc7155f7c075e5a22ece7159a64a1c9ba3d8ac9..48d29a0d05538cd1d992f3f086d826e78d0d8882 100644
+index 9aaf5626fcfe4a9b168e069df0265df7b535b76e..ece9c4656919d8dc408112142367791628dd5f8b 100644
 --- a/src/node_builtins.cc
 +++ b/src/node_builtins.cc
-@@ -775,6 +775,7 @@ void BuiltinLoader::RegisterExternalReferences(
+@@ -779,6 +779,7 @@ void BuiltinLoader::RegisterExternalReferences(
    registry->Register(GetNatives);
  
    RegisterExternalReferencesForInternalizedBuiltinCode(registry);
@@ -78,11 +78,11 @@ index 2bc7155f7c075e5a22ece7159a64a1c9ba3d8ac9..48d29a0d05538cd1d992f3f086d826e7
  
  }  // namespace builtins
 diff --git a/src/node_builtins.h b/src/node_builtins.h
-index 1cb85b9058d06555382e565dc32192a9fa48ed9f..cec9be01abd107e8612f70daf19b4834e118ffcf 100644
+index a73de23a1debfdac66873e0baccf882e383bfc36..7ac5291be093773ee7efd39e77e01bf5d5ce5247 100644
 --- a/src/node_builtins.h
 +++ b/src/node_builtins.h
 @@ -74,6 +74,8 @@ using BuiltinCodeCacheMap =
- // Generated by tools/js2c.py as node_javascript.cc
+ // Generated by tools/js2c.cc as node_javascript.cc
  void RegisterExternalReferencesForInternalizedBuiltinCode(
      ExternalReferenceRegistry* registry);
 +void EmbedderRegisterExternalReferencesForInternalizedBuiltinCode(
@@ -90,24 +90,11 @@ index 1cb85b9058d06555382e565dc32192a9fa48ed9f..cec9be01abd107e8612f70daf19b4834
  
  // Handles compilation and caching of built-in JavaScript modules and
  // bootstrap scripts, whose source are bundled into the binary as static data.
-diff --git a/tools/generate_config_gypi.py b/tools/generate_config_gypi.py
-index 45b3ac5006140fb55aad0e6b78084b753a947a76..8667857107e4f2481fd98032d4333b086fb7b479 100755
---- a/tools/generate_config_gypi.py
-+++ b/tools/generate_config_gypi.py
-@@ -21,7 +21,7 @@ import getnapibuildversion
- GN_RE = re.compile(r'(\w+)\s+=\s+(.*?)$', re.MULTILINE)
- 
- if sys.platform == 'win32':
--  GN = 'gn.exe'
-+  GN = 'gn.bat'
- else:
-   GN = 'gn'
- 
 diff --git a/tools/install.py b/tools/install.py
-index bf54249b66c0d4e179deaae5a9fd55568e694fe0..31b94d2e4b532d3b8202b512e2d2f41d29a2a546 100755
+index 17515720ba9c85d533465365188021074a8d30f4..7232be863d517c8445059a57c5938c2cbdeaf81b 100755
 --- a/tools/install.py
 +++ b/tools/install.py
-@@ -285,6 +285,7 @@ def headers(options, action):
+@@ -291,6 +291,7 @@ def headers(options, action):
        'include/v8-promise.h',
        'include/v8-proxy.h',
        'include/v8-regexp.h',
@@ -118,10 +105,10 @@ index bf54249b66c0d4e179deaae5a9fd55568e694fe0..31b94d2e4b532d3b8202b512e2d2f41d
 diff --git a/tools/js2c.cc b/tools/js2c.cc
 old mode 100644
 new mode 100755
-index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd786f64bb
+index 21992cbe894a880e3223c379326b62db22f2f12d..1296a5457422099035ba34f2b02624f2e9dfb0f0
 --- a/tools/js2c.cc
 +++ b/tools/js2c.cc
-@@ -30,6 +30,7 @@ namespace js2c {
+@@ -28,6 +28,7 @@ namespace js2c {
  int Main(int argc, char* argv[]);
  
  static bool is_verbose = false;
@@ -129,7 +116,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
  
  void Debug(const char* format, ...) {
    va_list arguments;
-@@ -196,6 +197,7 @@ const char* kTemplate = R"(
+@@ -175,6 +176,7 @@ const char* kTemplate = R"(
  #include "node_builtins.h"
  #include "node_external_reference.h"
  #include "node_internals.h"
@@ -137,7 +124,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
  
  namespace node {
  
-@@ -211,7 +213,11 @@ const ThreadsafeCopyOnWrite<BuiltinSourceMap> global_source_map {
+@@ -190,7 +192,11 @@ const ThreadsafeCopyOnWrite<BuiltinSourceMap> global_source_map {
  }  // anonymous namespace
  
  void BuiltinLoader::LoadJavaScriptSource() {
@@ -150,7 +137,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
  }
  
  void RegisterExternalReferencesForInternalizedBuiltinCode(
-@@ -228,6 +234,45 @@ UnionBytes BuiltinLoader::GetConfig() {
+@@ -207,6 +213,45 @@ UnionBytes BuiltinLoader::GetConfig() {
  }  // namespace node
  )";
  
@@ -196,7 +183,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
  Fragment Format(const Fragments& definitions,
                  const Fragments& initializers,
                  const Fragments& registrations) {
-@@ -237,13 +282,12 @@ Fragment Format(const Fragments& definitions,
+@@ -216,13 +261,12 @@ Fragment Format(const Fragments& definitions,
    size_t init_size = init_buf.size();
    std::vector<char> reg_buf = Join(registrations, "\n");
    size_t reg_size = reg_buf.size();
@@ -213,7 +200,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
                     static_cast<int>(def_buf.size()),
                     def_buf.data(),
                     static_cast<int>(init_buf.size()),
-@@ -834,12 +878,15 @@ int JS2C(const FileList& js_files,
+@@ -846,12 +890,15 @@ int JS2C(const FileList& js_files,
      }
    }
  
@@ -229,7 +216,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
    Fragment out = Format(definitions, initializers, registrations);
    return WriteIfChanged(out, dest);
  }
-@@ -865,6 +912,8 @@ int Main(int argc, char* argv[]) {
+@@ -877,6 +924,8 @@ int Main(int argc, char* argv[]) {
      std::string arg(argv[i]);
      if (arg == "--verbose") {
        is_verbose = true;
@@ -238,7 +225,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
      } else if (arg == "--root") {
        if (i == argc - 1) {
          fprintf(stderr, "--root must be followed by a path\n");
-@@ -913,6 +962,14 @@ int Main(int argc, char* argv[]) {
+@@ -925,6 +974,14 @@ int Main(int argc, char* argv[]) {
      }
    }
  
@@ -253,7 +240,7 @@ index a536b5dcd857275d3b02e361bd7d37a939f6b573..b2d5678d58a79774d5aeedc15ac5d5fd
    // Should have exactly 3 types: `.js`, `.mjs` and `.gypi`.
    assert(file_map.size() == 3);
    auto gypi_it = file_map.find(".gypi");
-@@ -939,6 +996,7 @@ int Main(int argc, char* argv[]) {
+@@ -951,6 +1008,7 @@ int Main(int argc, char* argv[]) {
    std::sort(mjs_it->second.begin(), mjs_it->second.end());
  
    return JS2C(js_it->second, mjs_it->second, gypi_it->second[0], output);
@@ -274,10 +261,10 @@ index 65d0e1be42f0a85418491ebb548278cf431aa6a0..d4a31342f1c6107b029394c6e1d00a1d
    except Exception as e:
      print(str(e))
 diff --git a/unofficial.gni b/unofficial.gni
-index c3b311e4a7f5444b07d4d7028d4621806959804e..de6ff5548ca5282199b7d85c11941c1fa351a9d9 100644
+index 9e496d99d7141bf42ef7374a3c676c7b333eeeab..3632d5bd21e277fcbd8d62dc65598a7f7c87f00e 100644
 --- a/unofficial.gni
 +++ b/unofficial.gni
-@@ -139,6 +139,7 @@ template("node_gn_build") {
+@@ -145,6 +145,7 @@ template("node_gn_build") {
      public_deps = [
        "deps/ada",
        "deps/uv",
@@ -285,15 +272,15 @@ index c3b311e4a7f5444b07d4d7028d4621806959804e..de6ff5548ca5282199b7d85c11941c1f
        "deps/simdjson",
        "$node_v8_path",
      ]
-@@ -150,7 +151,6 @@ template("node_gn_build") {
+@@ -156,7 +157,6 @@ template("node_gn_build") {
        "deps/llhttp",
        "deps/nbytes",
        "deps/nghttp2",
 -      "deps/ngtcp2",
        "deps/postject",
-       "deps/simdutf",
        "deps/sqlite",
-@@ -159,7 +159,11 @@ template("node_gn_build") {
+       "deps/uvwasi",
+@@ -165,7 +165,11 @@ template("node_gn_build") {
        "$node_v8_path:v8_libplatform",
      ]
  
@@ -305,28 +292,24 @@ index c3b311e4a7f5444b07d4d7028d4621806959804e..de6ff5548ca5282199b7d85c11941c1f
        "$target_gen_dir/node_javascript.cc",
      ] + gypi_values.node_sources
  
-@@ -178,8 +182,10 @@ template("node_gn_build") {
-       deps += [ "//third_party/icu" ]
+@@ -185,7 +189,7 @@ template("node_gn_build") {
      }
      if (node_use_openssl) {
--      deps += [ "deps/ncrypto" ]
--      public_deps += [ "deps/openssl" ]
-+      deps += [
-+        "deps/ncrypto",
-+        "//third_party/boringssl"
-+      ]
+       deps += [ "deps/ncrypto" ]
+-      public_deps += [ "$node_openssl_path" ]
++      public_deps += [ "//third_party/boringssl" ]
        sources += gypi_values.node_crypto_sources
      }
      if (node_enable_inspector) {
-@@ -276,6 +282,7 @@ template("node_gn_build") {
+@@ -282,6 +286,7 @@ template("node_gn_build") {
    }
  
    executable("node_js2c") {
 +    defines = []
      deps = [
-       "deps/simdutf",
        "deps/uv",
-@@ -286,26 +293,75 @@ template("node_gn_build") {
+       "$node_simdutf_path",
+@@ -292,26 +297,75 @@ template("node_gn_build") {
        "src/embedded_data.cc",
        "src/embedded_data.h",
      ]
@@ -412,7 +395,7 @@ index c3b311e4a7f5444b07d4d7028d4621806959804e..de6ff5548ca5282199b7d85c11941c1f
      outputs = [ "$target_gen_dir/node_javascript.cc" ]
  
      # Get the path to node_js2c executable of the host toolchain.
-@@ -319,11 +375,11 @@ template("node_gn_build") {
+@@ -325,11 +379,11 @@ template("node_gn_build") {
          get_label_info(":node_js2c($host_toolchain)", "name") +
          host_executable_suffix
  

+ 4 - 21
patches/node/build_allow_unbundling_of_node_js_dependencies.patch

@@ -13,28 +13,11 @@ We don't need to do this for zlib, as the existing gn workflow uses the same
 
 Upstreamed at https://github.com/nodejs/node/pull/55903
 
-diff --git a/node.gni b/node.gni
-index 18d58591e3d0f1f3512db00033c3410a65702864..99ec540ec41ddf5682eed7618ba87d6935b3b982 100644
---- a/node.gni
-+++ b/node.gni
-@@ -61,6 +61,12 @@ declare_args() {
-   #   1. cross-os compilation is not supported.
-   #   2. node_mksnapshot crashes when cross-compiling for x64 from arm64.
-   node_use_node_snapshot = false
-+
-+  # Allows downstream packagers (eg. Linux distributions) to build against system shared libraries.
-+  use_system_cares = false
-+  use_system_nghttp2 = false
-+  use_system_llhttp = false
-+  use_system_histogram = false
- }
- 
- assert(!node_enable_inspector || node_use_openssl,
 diff --git a/unofficial.gni b/unofficial.gni
-index 3d8b7957e791ce2fa2a8d0937a87b6010087803d..c23922a301a721662ff34bf6e54fd26b41f25ccc 100644
+index 08a4ed939fb1482a897def94128282fdfd63dc62..23367db388ce9e83e123d4c6e8c6325266dd52dc 100644
 --- a/unofficial.gni
 +++ b/unofficial.gni
-@@ -147,7 +147,6 @@ template("node_gn_build") {
+@@ -153,7 +153,6 @@ template("node_gn_build") {
        ":run_node_js2c",
        "deps/cares",
        "deps/histogram",
@@ -42,7 +25,7 @@ index 3d8b7957e791ce2fa2a8d0937a87b6010087803d..c23922a301a721662ff34bf6e54fd26b
        "deps/nbytes",
        "deps/nghttp2",
        "deps/postject",
-@@ -178,7 +177,17 @@ template("node_gn_build") {
+@@ -184,7 +183,17 @@ template("node_gn_build") {
        configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
        configs += [ "//build/config/gcc:symbol_visibility_default" ]
      }
@@ -61,7 +44,7 @@ index 3d8b7957e791ce2fa2a8d0937a87b6010087803d..c23922a301a721662ff34bf6e54fd26b
      if (v8_enable_i18n_support) {
        deps += [ "//third_party/icu" ]
      }
-@@ -205,6 +214,19 @@ template("node_gn_build") {
+@@ -211,6 +220,19 @@ template("node_gn_build") {
        sources += node_inspector.node_inspector_sources +
                   node_inspector.node_inspector_generated_sources
      }

+ 1 - 1
patches/node/build_compile_with_c_20_support.patch

@@ -10,7 +10,7 @@ V8 requires C++20 support as of https://chromium-review.googlesource.com/c/v8/v8
 This can be removed when Electron upgrades to a version of Node.js containing the required V8 version.
 
 diff --git a/common.gypi b/common.gypi
-index 74616453e2e047acbb9e25f2f93ebeab06011669..bce15fc4a8b3f2fa0b5a588e6a2b28d2b8b6ac45 100644
+index 755bd203173a69564be203ad58c33eb50680b204..a7a0ffde7209de51ffcbf0db0ed7efcf09ad606d 100644
 --- a/common.gypi
 +++ b/common.gypi
 @@ -518,7 +518,7 @@

+ 0 - 36
patches/node/build_don_t_redefine_win32_lean_and_mean.patch

@@ -1,36 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Shelley Vohr <[email protected]>
-Date: Fri, 23 Aug 2024 16:50:19 +0200
-Subject: build: don't redefine WIN32_LEAN_AND_MEAN
-
-https://github.com/nodejs/node/pull/53722 added a new define for WIN32_LEAN_AND_MEAN
-without first checking to see if it was defined - other areas in c-ares do this so
-we should here as well. Compilation errors occur otherwise:
-
-../../third_party/electron_node/deps/cares/include\ares_build.h(168,11): error: 'WIN32_LEAN_AND_MEAN' macro redefined [-Werror,-Wmacro-redefined]
-  168 | #  define WIN32_LEAN_AND_MEAN
-      |           ^
-<command line>(25,9): note: previous definition is here
-   25 | #define WIN32_LEAN_AND_MEAN 1
-      |         ^
-1 error generated.
-[287 processes, 49437/51449 @ 48.5/s : 1018.562s] CC obj/third_party/electron_node/deps/cares/cares/ares__socket.obj
-FAILED: obj/third_party/electron_node/deps/cares/cares/ares__socket.obj
-
-This should be upstreamed.
-
-diff --git a/deps/cares/include/ares_build.h b/deps/cares/include/ares_build.h
-index 18a92606a817145302c73b5081b4c989799bc620..bafd26d9210d2347fec41f028e9e65088b83c48c 100644
---- a/deps/cares/include/ares_build.h
-+++ b/deps/cares/include/ares_build.h
-@@ -165,7 +165,9 @@
- #  define CARES_TYPEOF_ARES_SOCKLEN_T int
- 
- #elif defined(_WIN32)
--#  define WIN32_LEAN_AND_MEAN
-+#  ifndef WIN32_LEAN_AND_MEAN
-+#    define WIN32_LEAN_AND_MEAN
-+#  endif
- #  define CARES_TYPEOF_ARES_SOCKLEN_T int
- #  define CARES_HAVE_WINDOWS_H          1
- #  define CARES_HAVE_SYS_TYPES_H        1

+ 19 - 33
patches/node/build_enable_perfetto.patch

@@ -64,7 +64,7 @@ index 251f51ec454f9cba4023b8b6729241ee753aac13..1de8cac6e3953ce9cab9db03530da327
  
  module.exports = {
 diff --git a/node.gyp b/node.gyp
-index 11474953b186c7b3ec2edb0539f34572e6c551b7..eeaaef8a06cdc2d17e89f9c719f9922e6e04ce92 100644
+index b21cfbf2fad024445e8d1ef8a6781141f788eb1a..55c6e01d9e879ce63524ec1504f8a23e00a2aa29 100644
 --- a/node.gyp
 +++ b/node.gyp
 @@ -174,7 +174,6 @@
@@ -264,27 +264,25 @@ index 18e4f43efaae3a60b924e697918867e604513194..7cbaf01235750138c680c8ec2ed5d206
    uint32_t current_chunk_seq_ = 1;
    uint32_t id_;
 diff --git a/src/tracing/node_trace_writer.cc b/src/tracing/node_trace_writer.cc
-index 8f053efe93324b9acbb4e85f7b974b4f7712e200..e331ed5567caa39ade90ce28cea69f1d10533812 100644
+index 8f053efe93324b9acbb4e85f7b974b4f7712e200..1801594e727ec7a2ef3b89603975f507078b88a1 100644
 --- a/src/tracing/node_trace_writer.cc
 +++ b/src/tracing/node_trace_writer.cc
-@@ -95,7 +95,7 @@ void NodeTraceWriter::OpenNewFileForStreaming() {
-     fd_ = -1;
+@@ -96,6 +96,7 @@ void NodeTraceWriter::OpenNewFileForStreaming() {
    }
  }
--
+ 
 +#ifndef V8_USE_PERFETTO
  void NodeTraceWriter::AppendTraceEvent(TraceObject* trace_event) {
    Mutex::ScopedLock scoped_lock(stream_mutex_);
    // If this is the first trace event, open a new file for streaming.
-@@ -112,7 +112,7 @@ void NodeTraceWriter::AppendTraceEvent(TraceObject* trace_event) {
+@@ -112,6 +113,7 @@ void NodeTraceWriter::AppendTraceEvent(TraceObject* trace_event) {
    ++total_traces_;
    json_trace_writer_->AppendTraceEvent(trace_event);
  }
--
 +#endif
+ 
  void NodeTraceWriter::FlushPrivate() {
    std::string str;
-   int highest_request_id;
 diff --git a/src/tracing/node_trace_writer.h b/src/tracing/node_trace_writer.h
 index cd965d77b7859ff2edcf781a934594b5a9b6d251..fe1714ba77fddef693d37eeb8c7a196ddfd15c26 100644
 --- a/src/tracing/node_trace_writer.h
@@ -300,7 +298,7 @@ index cd965d77b7859ff2edcf781a934594b5a9b6d251..fe1714ba77fddef693d37eeb8c7a196d
  
    static const int kTracesPerFile = 1 << 19;
 diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h
-index be0f55a409a71bf9c1763c36fdc252857228742e..827b5330b2f8c545338a46c548f8abf4aab7f50c 100644
+index a662a081dc3bf356bf93e4063fcb043e4d8df07b..c89cdfe2b2681fbf9946200a03d7d1f7bad21226 100644
 --- a/src/tracing/trace_event.h
 +++ b/src/tracing/trace_event.h
 @@ -69,8 +69,16 @@ enum CategoryGroupEnabledFlags {
@@ -336,21 +334,23 @@ index be0f55a409a71bf9c1763c36fdc252857228742e..827b5330b2f8c545338a46c548f8abf4
  
  // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method
  // on the convertable value will be called at flush time.
-@@ -319,10 +332,13 @@ class TraceEventHelper {
+@@ -319,12 +332,15 @@ class TraceEventHelper {
    static void SetAgent(Agent* agent);
  
    static inline const uint8_t* GetCategoryGroupEnabled(const char* group) {
 +#ifndef V8_USE_PERFETTO
      v8::TracingController* controller = GetTracingController();
      static const uint8_t disabled = 0;
-     if (UNLIKELY(controller == nullptr)) return &disabled;
+     if (controller == nullptr) [[unlikely]] {
+       return &disabled;
+     }
      return controller->GetCategoryGroupEnabled(group);
 +#endif
 +    return 0;
    }
  };
  
-@@ -460,6 +476,7 @@ static inline uint64_t AddTraceEventImpl(
+@@ -462,6 +478,7 @@ static inline uint64_t AddTraceEventImpl(
      const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
      const char** arg_names, const uint8_t* arg_types,
      const uint64_t* arg_values, unsigned int flags) {
@@ -358,14 +358,7 @@ index be0f55a409a71bf9c1763c36fdc252857228742e..827b5330b2f8c545338a46c548f8abf4
    std::unique_ptr<v8::ConvertableToTraceFormat> arg_convertibles[2];
    if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
      arg_convertibles[0].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
-@@ -469,13 +486,14 @@ static inline uint64_t AddTraceEventImpl(
-     arg_convertibles[1].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
-         static_cast<intptr_t>(arg_values[1])));
-   }
--  // DCHECK(num_args, 2);
-   v8::TracingController* controller =
-       node::tracing::TraceEventHelper::GetTracingController();
-   if (controller == nullptr) return 0;
+@@ -478,6 +495,8 @@ static inline uint64_t AddTraceEventImpl(
    return controller->AddTraceEvent(phase, category_group_enabled, name, scope, id,
                                     bind_id, num_args, arg_names, arg_types,
                                     arg_values, arg_convertibles, flags);
@@ -374,25 +367,18 @@ index be0f55a409a71bf9c1763c36fdc252857228742e..827b5330b2f8c545338a46c548f8abf4
  }
  
  static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
-@@ -483,6 +501,7 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
+@@ -485,6 +504,7 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
      const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
      const char** arg_names, const uint8_t* arg_types,
      const uint64_t* arg_values, unsigned int flags, int64_t timestamp) {
 +#ifndef V8_USE_PERFETTO
-   std::unique_ptr<v8::ConvertableToTraceFormat> arg_convertables[2];
+   std::unique_ptr<v8::ConvertableToTraceFormat> arg_convertibles[2];
    if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
-     arg_convertables[0].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
-@@ -492,19 +511,21 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
-     arg_convertables[1].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
-         static_cast<intptr_t>(arg_values[1])));
-   }
--  // DCHECK_LE(num_args, 2);
-   v8::TracingController* controller =
-       node::tracing::TraceEventHelper::GetTracingController();
-   if (controller == nullptr) return 0;
+     arg_convertibles[0].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
+@@ -501,12 +521,15 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
    return controller->AddTraceEventWithTimestamp(
        phase, category_group_enabled, name, scope, id, bind_id, num_args,
-       arg_names, arg_types, arg_values, arg_convertables, flags, timestamp);
+       arg_names, arg_types, arg_values, arg_convertibles, flags, timestamp);
 +#endif
 +  return 0;
  }
@@ -405,7 +391,7 @@ index be0f55a409a71bf9c1763c36fdc252857228742e..827b5330b2f8c545338a46c548f8abf4
    std::unique_ptr<v8::ConvertableToTraceFormat> arg_convertibles[2];
    if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
      arg_convertibles[0].reset(reinterpret_cast<v8::ConvertableToTraceFormat*>(
-@@ -520,6 +541,7 @@ static V8_INLINE void AddMetadataEventImpl(
+@@ -522,6 +545,7 @@ static V8_INLINE void AddMetadataEventImpl(
    return agent->GetTracingController()->AddMetadataEvent(
        category_group_enabled, name, num_args, arg_names, arg_types, arg_values,
        arg_convertibles, flags);

+ 4 - 4
patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch

@@ -7,7 +7,7 @@ Subject: build: ensure native module compilation fails if not using a new
 This should not be upstreamed, it is a quality-of-life patch for downstream module builders.
 
 diff --git a/common.gypi b/common.gypi
-index 229cb96c1385c597138719f2b01f78bd54ad44ab..74616453e2e047acbb9e25f2f93ebeab06011669 100644
+index 5d74876ab28f8c10bb9543f7652478514414d8d2..755bd203173a69564be203ad58c33eb50680b204 100644
 --- a/common.gypi
 +++ b/common.gypi
 @@ -86,6 +86,8 @@
@@ -40,10 +40,10 @@ index 229cb96c1385c597138719f2b01f78bd54ad44ab..74616453e2e047acbb9e25f2f93ebeab
        # list in v8/BUILD.gn.
        ['v8_enable_v8_checks == 1', {
 diff --git a/configure.py b/configure.py
-index d03db1970fd7a1629a7a7719a5ff267402ab4a66..ce055fb5dfc84c75c486b99f01fea6b9531ff54b 100755
+index 712ed40f77e54d52d5b3c52bb68e2b7d48879812..6bcb7450975636b5dbc689470663ee37903874d5 100755
 --- a/configure.py
 +++ b/configure.py
-@@ -1634,6 +1634,7 @@ def configure_library(lib, output, pkgname=None):
+@@ -1644,6 +1644,7 @@ def configure_library(lib, output, pkgname=None):
  def configure_v8(o, configs):
    set_configuration_variable(configs, 'v8_enable_v8_checks', release=1, debug=0)
  
@@ -52,7 +52,7 @@ index d03db1970fd7a1629a7a7719a5ff267402ab4a66..ce055fb5dfc84c75c486b99f01fea6b9
    o['variables']['v8_enable_javascript_promise_hooks'] = 1
    o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0
 diff --git a/src/node.h b/src/node.h
-index 60598f54114b2424f10706e57d8aa50c4634bcb0..40880ccaca694f28ae47676254b1c0cc36de0d93 100644
+index 7726d3de1e82689655e8fceb4135eec303498572..120e3a1042e29590cbbf4be258a1cd2d3d4f0043 100644
 --- a/src/node.h
 +++ b/src/node.h
 @@ -22,6 +22,12 @@

+ 4 - 4
patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch

@@ -10,7 +10,7 @@ JS errors and ensures embedder JS is loaded via LoadEmbedderJavaScriptSource.
 That method is generated by our modifications to js2c.cc in the BUILD.gn patch
 
 diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js
-index f5ecc15159f457cd0b8069c0427b7c758c916c4e..c9ce67391f321989b0af48159b4da3ab8ffc3e65 100644
+index 411eab8136d5957ae8a491bc38ffbdc88e59f5da..63c93b5be09692d0d4b6bfbb214b173b50ccca43 100644
 --- a/lib/internal/fs/watchers.js
 +++ b/lib/internal/fs/watchers.js
 @@ -292,12 +292,13 @@ function emitCloseNT(self) {
@@ -34,7 +34,7 @@ index f5ecc15159f457cd0b8069c0427b7c758c916c4e..c9ce67391f321989b0af48159b4da3ab
  let kResistStopPropagation;
  
 diff --git a/src/node_builtins.cc b/src/node_builtins.cc
-index 48d29a0d05538cd1d992f3f086d826e78d0d8882..8987234c2d08449242b5fd037ed314b725bc42a5 100644
+index ece9c4656919d8dc408112142367791628dd5f8b..c6a5f8cab45e9c3503ae1bb576cf94b4ca817e2a 100644
 --- a/src/node_builtins.cc
 +++ b/src/node_builtins.cc
 @@ -34,6 +34,7 @@ using v8::Value;
@@ -46,12 +46,12 @@ index 48d29a0d05538cd1d992f3f086d826e78d0d8882..8987234c2d08449242b5fd037ed314b7
    AddExternalizedBuiltin(
        "internal/deps/cjs-module-lexer/lexer",
 diff --git a/src/node_builtins.h b/src/node_builtins.h
-index cec9be01abd107e8612f70daf19b4834e118ffcf..3d9c6b962423555257bad4ebaad9ebd821d00042 100644
+index 7ac5291be093773ee7efd39e77e01bf5d5ce5247..c3c987d535285be84026ad0c633650bd2067d22d 100644
 --- a/src/node_builtins.h
 +++ b/src/node_builtins.h
 @@ -138,6 +138,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
  
-   // Generated by tools/js2c.py as node_javascript.cc
+   // Generated by tools/js2c.cc as node_javascript.cc
    void LoadJavaScriptSource();  // Loads data into source_
 +  void LoadEmbedderJavaScriptSource();  // Loads embedder data into source_
    UnionBytes GetConfig();       // Return data for config.gypi

+ 1 - 1
patches/node/build_restore_clang_as_default_compiler_on_macos.patch

@@ -11,7 +11,7 @@ node-gyp will use the result of `process.config` that reflects the environment
 in which the binary got built.
 
 diff --git a/common.gypi b/common.gypi
-index bce15fc4a8b3f2fa0b5a588e6a2b28d2b8b6ac45..289ab5d282e93c795eafb5fb992c3bbc4790a687 100644
+index a7a0ffde7209de51ffcbf0db0ed7efcf09ad606d..20fd68eeb878b51f361d72070d87338db3d9a8d4 100644
 --- a/common.gypi
 +++ b/common.gypi
 @@ -125,6 +125,7 @@

+ 6 - 37
patches/node/build_use_third_party_simdutf.patch

@@ -6,46 +6,15 @@ Subject: build: use third_party/simdutf
 use the Chromium version of simdutf to avoid duplicate symbols
 
 diff --git a/node.gni b/node.gni
-index 99ec540ec41ddf5682eed7618ba87d6935b3b982..274e627fe27b318218f10e982ca5a0773a9075a5 100644
+index 56a554175b805c1703f13d62041f8c80d6e94dd9..203b4abbc44df9e58083c819f61f9025104abdc6 100644
 --- a/node.gni
 +++ b/node.gni
-@@ -12,6 +12,8 @@ declare_args() {
- 
-   node_crypto_path = "//third_party/boringssl"
+@@ -14,7 +14,7 @@ declare_args() {
+   node_openssl_path = "//third_party/boringssl"
  
+   # The location of simdutf - use the one from node's deps by default.
+-  node_simdutf_path = "$node_path/deps/simdutf"
 +  node_simdutf_path = "//third_party/simdutf"
-+
+ 
    # The NODE_MODULE_VERSION defined in node_version.h.
    node_module_version = exec_script("$node_path/tools/getmoduleversion.py", [], "value")
- 
-diff --git a/unofficial.gni b/unofficial.gni
-index c23922a301a721662ff34bf6e54fd26b41f25ccc..988dd1d73e72ccd3a6eb10b326b8dc7fcd8e257b 100644
---- a/unofficial.gni
-+++ b/unofficial.gni
-@@ -150,7 +150,7 @@ template("node_gn_build") {
-       "deps/nbytes",
-       "deps/nghttp2",
-       "deps/postject",
--      "deps/simdutf",
-+      "$node_simdutf_path",
-       "deps/sqlite",
-       "deps/uvwasi",
-       "//third_party/zlib",
-@@ -305,7 +305,7 @@ template("node_gn_build") {
-   executable("node_js2c") {
-     defines = []
-     deps = [
--      "deps/simdutf",
-+      "$node_simdutf_path",
-       "deps/uv",
-     ]
-     sources = [
-@@ -412,7 +412,7 @@ template("node_gn_build") {
-       "deps/googletest",
-       "deps/googletest:gtest_main",
-       "deps/nbytes",
--      "deps/simdutf",
-+      "$node_simdutf_path",
-     ]
- 
-     sources = gypi_values.node_cctest_sources

+ 18 - 18
patches/node/chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch

@@ -8,30 +8,30 @@ they use themselves as the entry point. We should try to upstream some form
 of this.
 
 diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
-index d49941881e6cfd8647a6d44a57e0daaf1c874702..f696fb263b356a76b87cd4b6c4b1a0fd60a84afd 100644
+index ccd038dc136480cdd84a13e58f4012b71cd40928..5be90bc3df67751b55e67a05ac1c5b9a12d9c585 100644
 --- a/lib/internal/modules/cjs/loader.js
 +++ b/lib/internal/modules/cjs/loader.js
-@@ -1518,6 +1518,13 @@ Module.prototype._compile = function(content, filename, format) {
-   if (getOptionValue('--inspect-brk') && process._eval == null) {
-     if (!resolvedArgv) {
-       // We enter the repl if we're not given a filename argument.
-+      // process._firstFileName is used by Embedders to tell node what
-+      // the first "real" file is when they use themselves as the entry
-+      // point
-+      if (process._firstFileName) {
-+        resolvedArgv = process._firstFileName
-+        delete process._firstFileName
-+      } else
-       if (process.argv[1]) {
-         try {
-           resolvedArgv = Module._resolveFilename(process.argv[1], null, false);
+@@ -1563,6 +1563,13 @@ Module.prototype._compile = function(content, filename, format) {
+   this[kIsExecuting] = true;
+   if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) {
+     const { callAndPauseOnStart } = internalBinding('inspector');
++    // process._firstFileName is used by Embedders to tell node what
++    // the first "real" file is when they use themselves as the entry
++    // point
++    if (process._firstFileName) {
++      resolvedArgv = process._firstFileName;
++      delete process._firstFileName;
++    }
+     result = callAndPauseOnStart(compiledWrapper, thisValue, exports,
+                                  require, module, filename, dirname,
+                                  process, localGlobal, localBuffer);
 diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
-index cb96fd1bc4fcdce750ce241ee5f47f2ae39cfdc6..c46b270109697f7cc1683f8f9f463575e5040216 100644
+index 5d67892bb8e1fd265df414b3f41e62cdabbec873..89660076c41e1c05b26c17609a62a028c1e2ec5a 100644
 --- a/lib/internal/process/pre_execution.js
 +++ b/lib/internal/process/pre_execution.js
 @@ -243,12 +243,14 @@ function patchProcessObject(expandArgv1) {
-   if (expandArgv1 && process.argv[1] &&
-       !StringPrototypeStartsWith(process.argv[1], '-')) {
+   // the entry point.
+   if (expandArgv1 && process.argv[1] && process.argv[1][0] !== '-') {
      // Expand process.argv[1] into a full path.
 -    const path = require('path');
 -    try {

+ 5 - 5
patches/node/chore_disable_deprecation_ftbfs_in_simdjson_header.patch

@@ -11,10 +11,10 @@ Without this patch, building with simdjson fails with
 This patch can be removed once this is fixed upstream in simdjson.
 
 diff --git a/deps/simdjson/simdjson.h b/deps/simdjson/simdjson.h
-index ddb6f2e4e0a6edd23d5e16db07bc4bb18974d4aa..533dfea4d5fd3c7f6f7fdf0ea525479b11634fd3 100644
+index f21cd9381eef59ec43502c796fcaddb1b96525f5..e691fd24aa24d225f8c00fa5638be07265bfeeab 100644
 --- a/deps/simdjson/simdjson.h
 +++ b/deps/simdjson/simdjson.h
-@@ -3650,12 +3650,17 @@ inline std::ostream& operator<<(std::ostream& out, simdjson_result<padded_string
+@@ -3654,12 +3654,17 @@ inline std::ostream& operator<<(std::ostream& out, simdjson_result<padded_string
  
  } // namespace simdjson
  
@@ -32,7 +32,7 @@ index ddb6f2e4e0a6edd23d5e16db07bc4bb18974d4aa..533dfea4d5fd3c7f6f7fdf0ea525479b
  namespace simdjson {
  namespace internal {
  
-@@ -4033,6 +4038,9 @@ inline simdjson_result<padded_string> padded_string::load(std::string_view filen
+@@ -4037,6 +4042,9 @@ inline simdjson_result<padded_string> padded_string::load(std::string_view filen
  
  } // namespace simdjson
  
@@ -42,7 +42,7 @@ index ddb6f2e4e0a6edd23d5e16db07bc4bb18974d4aa..533dfea4d5fd3c7f6f7fdf0ea525479b
  inline simdjson::padded_string operator "" _padded(const char *str, size_t len) {
    return simdjson::padded_string(str, len);
  }
-@@ -4041,6 +4049,8 @@ inline simdjson::padded_string operator "" _padded(const char8_t *str, size_t le
+@@ -4045,6 +4053,8 @@ inline simdjson::padded_string operator "" _padded(const char8_t *str, size_t le
    return simdjson::padded_string(reinterpret_cast<const char8_t *>(str), len);
  }
  #endif
@@ -51,7 +51,7 @@ index ddb6f2e4e0a6edd23d5e16db07bc4bb18974d4aa..533dfea4d5fd3c7f6f7fdf0ea525479b
  #endif // SIMDJSON_PADDED_STRING_INL_H
  /* end file simdjson/padded_string-inl.h */
  /* skipped duplicate #include "simdjson/padded_string_view.h" */
-@@ -118280,4 +118290,4 @@ namespace simdjson {
+@@ -118292,4 +118302,4 @@ namespace simdjson {
  /* end file simdjson/ondemand.h */
  
  #endif // SIMDJSON_H

+ 6 - 6
patches/node/chore_expose_importmoduledynamically_and.patch

@@ -11,7 +11,7 @@ its own blended handler between Node and Blink.
 Not upstreamable.
 
 diff --git a/lib/internal/modules/esm/utils.js b/lib/internal/modules/esm/utils.js
-index d393d4336a0c1e681e4f6b4e5c7cf2bcc5fc287e..807cb5172e0c2178b6c20e81f8175141d3a0284f 100644
+index 99061e62976e7cb24be81e8632b0e21d1e9adf9a..bbc9311c059e8ab0328c5f92b21a6be57620717e 100644
 --- a/lib/internal/modules/esm/utils.js
 +++ b/lib/internal/modules/esm/utils.js
 @@ -30,7 +30,7 @@ const {
@@ -23,7 +23,7 @@ index d393d4336a0c1e681e4f6b4e5c7cf2bcc5fc287e..807cb5172e0c2178b6c20e81f8175141
  const {
    loadPreloadModules,
    initializeFrozenIntrinsics,
-@@ -273,12 +273,13 @@ let _forceDefaultLoader = false;
+@@ -274,12 +274,13 @@ let _forceDefaultLoader = false;
   * @param {boolean} [forceDefaultLoader=false] - A boolean indicating disabling custom loaders.
   */
  function initializeESM(forceDefaultLoader = false) {
@@ -40,10 +40,10 @@ index d393d4336a0c1e681e4f6b4e5c7cf2bcc5fc287e..807cb5172e0c2178b6c20e81f8175141
  
  /**
 diff --git a/src/module_wrap.cc b/src/module_wrap.cc
-index 48b61e8b7600701c4992a98ff802614ce915faee..4e9835e502a8d078a448aa4253f37de0f49f4854 100644
+index 8be6dbd1d0262ccbb2318de1d98e344e9b21a510..1509fc54fe9767e101b107509b4b2d6c821ce95d 100644
 --- a/src/module_wrap.cc
 +++ b/src/module_wrap.cc
-@@ -813,7 +813,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
+@@ -823,7 +823,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
    return module->module_.Get(isolate);
  }
  
@@ -52,7 +52,7 @@ index 48b61e8b7600701c4992a98ff802614ce915faee..4e9835e502a8d078a448aa4253f37de0
      Local<Context> context,
      Local<v8::Data> host_defined_options,
      Local<Value> resource_name,
-@@ -878,12 +878,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
+@@ -888,12 +888,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
    Realm* realm = Realm::GetCurrent(args);
    HandleScope handle_scope(isolate);
  
@@ -68,7 +68,7 @@ index 48b61e8b7600701c4992a98ff802614ce915faee..4e9835e502a8d078a448aa4253f37de0
  }
  
  void ModuleWrap::HostInitializeImportMetaObjectCallback(
-@@ -925,13 +926,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
+@@ -935,13 +936,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
    Realm* realm = Realm::GetCurrent(args);
    Isolate* isolate = realm->isolate();
  

+ 6 - 6
patches/node/cli_remove_deprecated_v8_flag.patch

@@ -18,10 +18,10 @@ Reviewed-By: Michaël Zasso <[email protected]>
 Reviewed-By: Yagiz Nizipli <[email protected]>
 
 diff --git a/doc/api/cli.md b/doc/api/cli.md
-index 0cfed4a4a91a3d3fb5aee6c9a4db3405ba836565..61d980a12fcf7c799e726e1462c65ce478a8ed0c 100644
+index 770d2ca4fcf003352c2c12815ac885a7a5e67b7f..4af66f690e626b0159a88d58f6ee81391573ebab 100644
 --- a/doc/api/cli.md
 +++ b/doc/api/cli.md
-@@ -3151,7 +3151,6 @@ V8 options that are allowed are:
+@@ -3232,7 +3232,6 @@ V8 options that are allowed are:
  * `--disallow-code-generation-from-strings`
  * `--enable-etw-stack-walking`
  * `--expose-gc`
@@ -30,10 +30,10 @@ index 0cfed4a4a91a3d3fb5aee6c9a4db3405ba836565..61d980a12fcf7c799e726e1462c65ce4
  * `--jitless`
  * `--max-old-space-size`
 diff --git a/src/node_options.cc b/src/node_options.cc
-index 4b3f7751db2871c8ce76b197a84a2417097030ea..21e53e1053fe2e4194d91b27a726d3a1306b1683 100644
+index ec419cf96a14989338e3261b85c92b81ba8b50d9..5a4d536ff0d090fa6b43ea4cbd403d4aa23171c1 100644
 --- a/src/node_options.cc
 +++ b/src/node_options.cc
-@@ -922,11 +922,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
+@@ -970,11 +970,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
              "disallow eval and friends",
              V8Option{},
              kAllowedInEnvvar);
@@ -46,10 +46,10 @@ index 4b3f7751db2871c8ce76b197a84a2417097030ea..21e53e1053fe2e4194d91b27a726d3a1
              "disable runtime allocation of executable memory",
              V8Option{},
 diff --git a/test/parallel/test-cli-node-options.js b/test/parallel/test-cli-node-options.js
-index e898a81af09ca6852ddc866310e5b8e0dc82971b..22d5a342df5d55f065383a6ebe1aebe59dc0f8d2 100644
+index 03ffe7aa03f48156f04bb527316221ec10e7e0df..69bf136559c1a8a18a7bfc444a439d161f622635 100644
 --- a/test/parallel/test-cli-node-options.js
 +++ b/test/parallel/test-cli-node-options.js
-@@ -70,7 +70,6 @@ if (common.hasCrypto) {
+@@ -72,7 +72,6 @@ if (common.hasCrypto) {
  expect('--abort_on-uncaught_exception', 'B\n');
  expect('--disallow-code-generation-from-strings', 'B\n');
  expect('--expose-gc', 'B\n');

+ 3 - 3
patches/node/enable_crashpad_linux_node_processes.patch

@@ -8,7 +8,7 @@ to child processes spawned with `ELECTRON_RUN_AS_NODE` which is used
 by the crashpad client to connect with the handler process.
 
 diff --git a/lib/child_process.js b/lib/child_process.js
-index 580a441a803bdd0b57871c0cdd8af576f11609b1..755712d24219de7ffe491957d941df7c8cf7baad 100644
+index bb27670112c1ea42c7ff00883fe4b684544d9cd4..4d4da798ce59ce42e42d1f05fccf07699c033d46 100644
 --- a/lib/child_process.js
 +++ b/lib/child_process.js
 @@ -61,6 +61,7 @@ let debug = require('internal/util/debuglog').debuglog(
@@ -27,7 +27,7 @@ index 580a441a803bdd0b57871c0cdd8af576f11609b1..755712d24219de7ffe491957d941df7c
    args = [...execArgv, modulePath, ...args];
  
    if (typeof options.stdio === 'string') {
-@@ -617,6 +617,22 @@ function normalizeSpawnArguments(file, args, options) {
+@@ -609,6 +609,22 @@ function normalizeSpawnArguments(file, args, options) {
                      'options.windowsVerbatimArguments');
    }
  
@@ -50,7 +50,7 @@ index 580a441a803bdd0b57871c0cdd8af576f11609b1..755712d24219de7ffe491957d941df7c
    if (options.shell) {
      validateArgumentNullCheck(options.shell, 'options.shell');
      const command = ArrayPrototypeJoin([file, ...args], ' ');
-@@ -650,7 +666,6 @@ function normalizeSpawnArguments(file, args, options) {
+@@ -642,7 +658,6 @@ function normalizeSpawnArguments(file, args, options) {
      ArrayPrototypeUnshift(args, file);
    }
  

+ 23 - 29
patches/node/feat_add_uv_loop_interrupt_on_io_change_option_to_uv_loop_configure.patch

@@ -6,10 +6,10 @@ Subject: feat: add UV_LOOP_INTERRUPT_ON_IO_CHANGE option to uv_loop_configure
 https://github.com/libuv/libuv/pull/3308
 
 diff --git a/deps/uv/docs/src/loop.rst b/deps/uv/docs/src/loop.rst
-index 0f5ddfb3ca21b7e5b38d0a4ce4b9e77387597199..ba815202fb157aa82859ec0518523cf6f2ec6ba1 100644
+index d1f41e1c9f44838410326df23b1b175fa16ba199..dcf69093469b611a6f9db2bb84530456bc543301 100644
 --- a/deps/uv/docs/src/loop.rst
 +++ b/deps/uv/docs/src/loop.rst
-@@ -73,7 +73,15 @@ API
+@@ -86,6 +86,12 @@ API
  
        This option is necessary to use :c:func:`uv_metrics_idle_time`.
  
@@ -19,26 +19,21 @@ index 0f5ddfb3ca21b7e5b38d0a4ce4b9e77387597199..ba815202fb157aa82859ec0518523cf6
 +      This option is usually when implementing event loop integration, to make
 +      the polling of backend fd interrupt to recognize the changes of IO events.
 +
-     .. versionchanged:: 1.39.0 added the UV_METRICS_IDLE_TIME option.
-+    .. versionchanged:: 1.43.0 added the UV_LOOP_INTERRUPT_ON_IO_CHANGE option.
-+
- 
- .. c:function:: int uv_loop_close(uv_loop_t* loop)
+     - UV_LOOP_ENABLE_IO_URING_SQPOLL: Enable SQPOLL io_uring instance to handle
+       asynchronous file system operations.
  
 diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
-index a62b3fa69b1087847f37c7093954e19a07959b74..7f48b7daa87d1a5b14bc6f641b60f21263fa5ec3 100644
+index 9e450c5110fe57117b686bf683cc6631f37efaeb..f75a496071ac3396cbc6dec819eaab7294609deb 100644
 --- a/deps/uv/include/uv.h
 +++ b/deps/uv/include/uv.h
-@@ -260,7 +260,8 @@ typedef struct uv_metrics_s uv_metrics_t;
- 
+@@ -261,6 +261,7 @@ typedef struct uv_metrics_s uv_metrics_t;
  typedef enum {
    UV_LOOP_BLOCK_SIGNAL = 0,
--  UV_METRICS_IDLE_TIME
-+  UV_METRICS_IDLE_TIME,
-+  UV_LOOP_INTERRUPT_ON_IO_CHANGE
+   UV_METRICS_IDLE_TIME,
++  UV_LOOP_INTERRUPT_ON_IO_CHANGE,
+   UV_LOOP_USE_IO_URING_SQPOLL
+ #define UV_LOOP_USE_IO_URING_SQPOLL UV_LOOP_USE_IO_URING_SQPOLL
  } uv_loop_option;
- 
- typedef enum {
 diff --git a/deps/uv/src/unix/async.c b/deps/uv/src/unix/async.c
 index 0ff2669e30a628dbb2df9e28ba14b38cf14114e5..117190ef26338944b78dbed7380c631de8057223 100644
 --- a/deps/uv/src/unix/async.c
@@ -101,10 +96,10 @@ index 0ff2669e30a628dbb2df9e28ba14b38cf14114e5..117190ef26338944b78dbed7380c631d
  static int uv__async_start(uv_loop_t* loop) {
    int pipefd[2];
 diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
-index 965e7f775250cf9899266bc3aaf62eda69367264..45b3dec662b093a61af356e431416530b35343d2 100644
+index 0c52ccf2ad7b2dcae77a7bc4b3af9d1a1346ce18..13cd33a7d3031c5e19c9418a18217d1e4158c82e 100644
 --- a/deps/uv/src/unix/core.c
 +++ b/deps/uv/src/unix/core.c
-@@ -927,6 +927,9 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
+@@ -937,6 +937,9 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
      loop->watchers[w->fd] = w;
      loop->nfds++;
    }
@@ -114,7 +109,7 @@ index 965e7f775250cf9899266bc3aaf62eda69367264..45b3dec662b093a61af356e431416530
  }
  
  
-@@ -958,6 +961,9 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
+@@ -968,6 +971,9 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
    }
    else if (uv__queue_empty(&w->watcher_queue))
      uv__queue_insert_tail(&loop->watcher_queue, &w->watcher_queue);
@@ -124,7 +119,7 @@ index 965e7f775250cf9899266bc3aaf62eda69367264..45b3dec662b093a61af356e431416530
  }
  
  
-@@ -974,6 +980,9 @@ void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
+@@ -984,6 +990,9 @@ void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
  void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {
    if (uv__queue_empty(&w->pending_queue))
      uv__queue_insert_tail(&loop->pending_queue, &w->pending_queue);
@@ -135,22 +130,21 @@ index 965e7f775250cf9899266bc3aaf62eda69367264..45b3dec662b093a61af356e431416530
  
  
 diff --git a/deps/uv/src/unix/loop.c b/deps/uv/src/unix/loop.c
-index a9468e8e19cbede795032980c47eb83aee1e0c68..2d28cf48efc3718de19b901b7e08b8a857d20740 100644
+index 179ee999d8052e779dc692aeb5b673d210aaa997..03cca2c491015e5ef958f61a0167d29dfc56e247 100644
 --- a/deps/uv/src/unix/loop.c
 +++ b/deps/uv/src/unix/loop.c
-@@ -217,6 +217,11 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) {
-     return 0;
+@@ -224,6 +224,10 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) {
    }
+ #endif
  
 +  if (option == UV_LOOP_INTERRUPT_ON_IO_CHANGE) {
 +    lfields->flags |= UV_LOOP_INTERRUPT_ON_IO_CHANGE;
 +    return 0;
 +  }
-+
+ 
    if (option != UV_LOOP_BLOCK_SIGNAL)
      return UV_ENOSYS;
- 
-@@ -226,3 +231,40 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) {
+@@ -234,3 +238,40 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) {
    loop->flags |= UV_LOOP_BLOCK_SIGPROF;
    return 0;
  }
@@ -192,7 +186,7 @@ index a9468e8e19cbede795032980c47eb83aee1e0c68..2d28cf48efc3718de19b901b7e08b8a8
 +  abort();
 +}
 diff --git a/deps/uv/src/uv-common.h b/deps/uv/src/uv-common.h
-index cd57e5a35153d0557351b60cce0c5be7a4468b60..660caef30b1637b8009de5e55ee34f48d17e4dd0 100644
+index 4baede2e506ee1787d554a0ec75bc9eb346fc8f2..385d4f420b50bfd2dc23f119d535c0442a3ce4e7 100644
 --- a/deps/uv/src/uv-common.h
 +++ b/deps/uv/src/uv-common.h
 @@ -144,6 +144,8 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap);
@@ -465,10 +459,10 @@ index 6e9917239aa5626dd56fffd6eb2469d3e63224bf..b0da9d1cddc69428e9fb3379d1338cf8
    MAKE_VALGRIND_HAPPY(loop);
    return 0;
 diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
-index d30f02faa8515ca3a995490d53f2e85fda11c6a2..a392f5e3d701b0d973db2bbc6553977ce55a8775 100644
+index e07bd61ecf73c122a553d5d8232a7478980751a5..21cf8c09edac15ba5ea010d54d3e158e0d1b7e5b 100644
 --- a/deps/uv/test/test-list.h
 +++ b/deps/uv/test/test-list.h
-@@ -276,6 +276,7 @@ TEST_DECLARE   (process_priority)
+@@ -279,6 +279,7 @@ TEST_DECLARE   (process_priority)
  TEST_DECLARE   (has_ref)
  TEST_DECLARE   (active)
  TEST_DECLARE   (embed)
@@ -476,7 +470,7 @@ index d30f02faa8515ca3a995490d53f2e85fda11c6a2..a392f5e3d701b0d973db2bbc6553977c
  TEST_DECLARE   (async)
  TEST_DECLARE   (async_null_cb)
  TEST_DECLARE   (eintr_handling)
-@@ -906,6 +907,7 @@ TASK_LIST_START
+@@ -919,6 +920,7 @@ TASK_LIST_START
    TEST_ENTRY  (active)
  
    TEST_ENTRY  (embed)

+ 0 - 60
patches/node/fix_-wextra-semi_errors_in_nghttp2_helper_h.patch

@@ -1,60 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Shelley Vohr <[email protected]>
-Date: Wed, 16 Oct 2024 16:09:37 +0200
-Subject: fix: -Wextra-semi errors in nghttp2_helper.h
-
-Introduced in https://github.com/nodejs/node/pull/52966
-
-Upstreamed in https://github.com/nghttp2/nghttp2/pull/2258
-
-diff --git a/deps/nghttp2/lib/nghttp2_helper.h b/deps/nghttp2/lib/nghttp2_helper.h
-index 89b0d4f535db795cd1df582475c02b2f4d1ac98f..f5de6290dab0e17ae3aff10230dd8ad7414f9631 100644
---- a/deps/nghttp2/lib/nghttp2_helper.h
-+++ b/deps/nghttp2/lib/nghttp2_helper.h
-@@ -38,28 +38,28 @@
- #define nghttp2_max_def(SUFFIX, T)                                             \
-   static inline T nghttp2_max_##SUFFIX(T a, T b) { return a < b ? b : a; }
- 
--nghttp2_max_def(int8, int8_t);
--nghttp2_max_def(int16, int16_t);
--nghttp2_max_def(int32, int32_t);
--nghttp2_max_def(int64, int64_t);
--nghttp2_max_def(uint8, uint8_t);
--nghttp2_max_def(uint16, uint16_t);
--nghttp2_max_def(uint32, uint32_t);
--nghttp2_max_def(uint64, uint64_t);
--nghttp2_max_def(size, size_t);
-+nghttp2_max_def(int8, int8_t)
-+nghttp2_max_def(int16, int16_t)
-+nghttp2_max_def(int32, int32_t)
-+nghttp2_max_def(int64, int64_t)
-+nghttp2_max_def(uint8, uint8_t)
-+nghttp2_max_def(uint16, uint16_t)
-+nghttp2_max_def(uint32, uint32_t)
-+nghttp2_max_def(uint64, uint64_t)
-+nghttp2_max_def(size, size_t)
- 
- #define nghttp2_min_def(SUFFIX, T)                                             \
-   static inline T nghttp2_min_##SUFFIX(T a, T b) { return a < b ? a : b; }
- 
--nghttp2_min_def(int8, int8_t);
--nghttp2_min_def(int16, int16_t);
--nghttp2_min_def(int32, int32_t);
--nghttp2_min_def(int64, int64_t);
--nghttp2_min_def(uint8, uint8_t);
--nghttp2_min_def(uint16, uint16_t);
--nghttp2_min_def(uint32, uint32_t);
--nghttp2_min_def(uint64, uint64_t);
--nghttp2_min_def(size, size_t);
-+nghttp2_min_def(int8, int8_t)
-+nghttp2_min_def(int16, int16_t)
-+nghttp2_min_def(int32, int32_t)
-+nghttp2_min_def(int64, int64_t)
-+nghttp2_min_def(uint8, uint8_t)
-+nghttp2_min_def(uint16, uint16_t)
-+nghttp2_min_def(uint32, uint32_t)
-+nghttp2_min_def(uint64, uint64_t)
-+nghttp2_min_def(size, size_t)
- 
- #define lstreq(A, B, N) ((sizeof((A)) - 1) == (N) && memcmp((A), (B), (N)) == 0)
- 

+ 1 - 1
patches/node/fix_add_default_values_for_variables_in_common_gypi.patch

@@ -7,7 +7,7 @@ common.gypi is a file that's included in the node header bundle, despite
 the fact that we do not build node with gyp.
 
 diff --git a/common.gypi b/common.gypi
-index a97e77860e151f5126515d65ef99b34aa7301f76..229cb96c1385c597138719f2b01f78bd54ad44ab 100644
+index 62f26bb07d27a02aedf18fdd1191b282f9340cac..5d74876ab28f8c10bb9543f7652478514414d8d2 100644
 --- a/common.gypi
 +++ b/common.gypi
 @@ -88,6 +88,23 @@

+ 4 - 4
patches/node/fix_assert_module_in_the_renderer_process.patch

@@ -44,10 +44,10 @@ index 59b5a16f1309a5e4055bccfdb7a529045ad30402..bfdaf6211466a01b64b7942f7b16c480
    let filename = call.getFileName();
    const line = call.getLineNumber() - 1;
 diff --git a/src/api/environment.cc b/src/api/environment.cc
-index a3c5697ef5b20a9dc43bfcd3513e703989f64d2d..837fdc8c79c6d80393b0c8ac9a18e4dd5e5a8dba 100644
+index fc9b056d2f7e25109100fbde5f3ab0aebc8c619a..32fc075e97eebca6c47e796ac5308915746ffa2a 100644
 --- a/src/api/environment.cc
 +++ b/src/api/environment.cc
-@@ -244,6 +244,9 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
+@@ -247,6 +247,9 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
      auto* prepare_stack_trace_cb = s.prepare_stack_trace_callback ?
          s.prepare_stack_trace_callback : PrepareStackTraceCallback;
      isolate->SetPrepareStackTraceCallback(prepare_stack_trace_cb);
@@ -58,10 +58,10 @@ index a3c5697ef5b20a9dc43bfcd3513e703989f64d2d..837fdc8c79c6d80393b0c8ac9a18e4dd
  }
  
 diff --git a/src/node_options.cc b/src/node_options.cc
-index 29630fcccc3bd9d24ad6aec64bef2fedfc3c4031..4b3f7751db2871c8ce76b197a84a2417097030ea 100644
+index f70e0917f6caa66210107cdb2ef891685563ba96..ec419cf96a14989338e3261b85c92b81ba8b50d9 100644
 --- a/src/node_options.cc
 +++ b/src/node_options.cc
-@@ -1464,14 +1464,16 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
+@@ -1517,14 +1517,16 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
    }
    Isolate* isolate = args.GetIsolate();
  

+ 51 - 157
patches/node/fix_crypto_tests_to_run_with_bssl.patch

@@ -11,7 +11,7 @@ before it's acceptable to upstream, as this patch comments out a couple
 of tests that upstream probably cares about.
 
 diff --git a/test/common/index.js b/test/common/index.js
-index 172cdb6b049824539a9850789e0e7c5baf613367..c29abc18191aec78ad8eb810093a9a4ef9e854e4 100644
+index d1eaf6e69f603b0a7037e44be6ef185283972090..e3f26d32dbad2e4ccb47dea028dbf1a855525cfb 100644
 --- a/test/common/index.js
 +++ b/test/common/index.js
 @@ -65,6 +65,8 @@ const opensslVersionNumber = (major = 0, minor = 0, patch = 0) => {
@@ -23,7 +23,7 @@ index 172cdb6b049824539a9850789e0e7c5baf613367..c29abc18191aec78ad8eb810093a9a4e
  let OPENSSL_VERSION_NUMBER;
  const hasOpenSSL = (major = 0, minor = 0, patch = 0) => {
    if (!hasCrypto) return false;
-@@ -996,6 +998,7 @@ const common = {
+@@ -1008,6 +1010,7 @@ const common = {
    mustNotMutateObjectDeep,
    mustSucceed,
    nodeProcessAborted,
@@ -123,7 +123,7 @@ index 81a469c226c261564dee1e0b06b6571b18a41f1f..58b66045dba4201b7ebedd78b129420f
  
  const availableCurves = new Set(crypto.getCurves());
 diff --git a/test/parallel/test-crypto-dh-errors.js b/test/parallel/test-crypto-dh-errors.js
-index fcf1922bcdba733af6c22f142db4f7b099947757..9f72ae4e41a113e752f40795103c2af514538780 100644
+index 476ca64b4425b5b8b0fa2dc8352ee6f03d563813..2250a8f24a875d6af198426891870b450078ee5f 100644
 --- a/test/parallel/test-crypto-dh-errors.js
 +++ b/test/parallel/test-crypto-dh-errors.js
 @@ -32,9 +32,9 @@ for (const bits of [-1, 0, 1]) {
@@ -138,24 +138,6 @@ index fcf1922bcdba733af6c22f142db4f7b099947757..9f72ae4e41a113e752f40795103c2af5
      });
    }
  }
-@@ -43,7 +43,7 @@ for (const g of [-1, 1]) {
-   const ex = {
-     code: 'ERR_OSSL_DH_BAD_GENERATOR',
-     name: 'Error',
--    message: /bad generator/,
-+    message: /bad generator|BAD_GENERATOR/,
-   };
-   assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
-   assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
-@@ -55,7 +55,7 @@ for (const g of [Buffer.from([]),
-   const ex = {
-     code: 'ERR_OSSL_DH_BAD_GENERATOR',
-     name: 'Error',
--    message: /bad generator/,
-+    message: /bad generator|BAD_GENERATOR/,
-   };
-   assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
-   assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
 diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
 index 9ebe14011eed223994e0901bc22dcc582b4b0739..e78f90eb76380916ce7098fb517c83a954edb053 100644
 --- a/test/parallel/test-crypto-dh.js
@@ -319,19 +301,6 @@ index f1f14b472997e76bb4100edb1c6cf4fc24d1074d..5057e3f9bc5bb78aceffa5e79530f8ce
  });
  
  // No-pad encrypted string should return the same:
-diff --git a/test/parallel/test-crypto-private-decrypt-gh32240.js b/test/parallel/test-crypto-private-decrypt-gh32240.js
-index 1785f5eef3d202976666081d09850ed744d83446..e88227a215ba4f7fa196f7642ae694a57d55b3ca 100644
---- a/test/parallel/test-crypto-private-decrypt-gh32240.js
-+++ b/test/parallel/test-crypto-private-decrypt-gh32240.js
-@@ -24,7 +24,7 @@ const pkeyEncrypted =
-   pair.privateKey.export({
-     type: 'pkcs1',
-     format: 'pem',
--    cipher: 'aes128',
-+    cipher: 'aes-128-cbc',
-     passphrase: 'secret',
-   });
- 
 diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js
 index 5f4fafdfffbf726b7cb39c472baa3df25c9794cf..d52376da2cddd90adcdf8a9b7dcd03e348d9f2b4 100644
 --- a/test/parallel/test-crypto-rsa-dsa.js
@@ -395,7 +364,7 @@ index 338a19b0e88ad6f08d2f6b6a5d38b9980996ce11..a4ee215575d072450ba66c558ddca88b
    };
    assert.throws(() => crypto.scrypt('pass', 'salt', 1, options, () => {}),
 diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js
-index 9dd586a1a1f9a00d9bb0af5b0532e81e7b96a5ce..a37e6d50914345829c8260a97949cee7d17ab676 100644
+index 8a263ec3350f5540591ac02e70fa2f552b9ac477..dcc4c2ec816d28f1b27df1c358cfce66f1a3a03b 100644
 --- a/test/parallel/test-crypto-sign-verify.js
 +++ b/test/parallel/test-crypto-sign-verify.js
 @@ -29,7 +29,7 @@ const keySize = 2048;
@@ -471,92 +440,58 @@ index 008ab129f0e019c659eecf5a76b7eb412c947fe3..6688f5d916f50e1e4fcfff1619c8634a
  
  cipher.end('Papaya!');  // Should not cause an unhandled exception.
 diff --git a/test/parallel/test-crypto-x509.js b/test/parallel/test-crypto-x509.js
-index 89a7521544f7051edc1779138551bbad1972b3fb..91df6acc65d4003999f29f0fa5f639056b21ee3b 100644
+index bd906c25b9ee194ff34fe5fb8ecb68d7a672138c..5b631a32d07bd916ff7cd847e52b26f694bd00c6 100644
 --- a/test/parallel/test-crypto-x509.js
 +++ b/test/parallel/test-crypto-x509.js
-@@ -111,7 +111,7 @@ const der = Buffer.from(
-     '5A:42:63:E0:21:2F:D6:70:63:07:96:6F:27:A7:78:12:08:02:7A:8B'
-   );
-   assert.strictEqual(x509.keyUsage, undefined);
--  assert.strictEqual(x509.serialNumber, '147D36C1C2F74206DE9FAB5F2226D78ADB00A426');
-+  assert.match(x509.serialNumber, /147D36C1C2F74206DE9FAB5F2226D78ADB00A426/i);
- 
-   assert.deepStrictEqual(x509.raw, der);
- 
-@@ -253,6 +253,16 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
-   });
-   mc.port2.postMessage(x509);
- 
-+  const modulusOSSL = 'D456320AFB20D3827093DC2C4284ED04DFBABD56E1DDAE529E28B790CD42' +
-+                      '56DB273349F3735FFD337C7A6363ECCA5A27B7F73DC7089A96C6D886DB0C' +
-+                      '62388F1CDD6A963AFCD599D5800E587A11F908960F84ED50BA25A28303EC' +
-+                      'DA6E684FBE7BAEDC9CE8801327B1697AF25097CEE3F175E400984C0DB6A8' +
-+                      'EB87BE03B4CF94774BA56FFFC8C63C68D6ADEB60ABBE69A7B14AB6A6B9E7' +
-+                      'BAA89B5ADAB8EB07897C07F6D4FA3D660DFF574107D28E8F63467A788624' +
-+                      'C574197693E959CEA1362FFAE1BBA10C8C0D88840ABFEF103631B2E8F5C3' +
-+                      '9B5548A7EA57E8A39F89291813F45A76C448033A2B7ED8403F4BAA147CF3' +
-+                      '5E2D2554AA65CE49695797095BF4DC6B';
-+
-   // Verify that legacy encoding works
-   const legacyObjectCheck = {
-     subject: Object.assign({ __proto__: null }, {
-@@ -277,15 +287,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
-       'OCSP - URI': ['http://ocsp.nodejs.org/'],
-       'CA Issuers - URI': ['http://ca.nodejs.org/ca.cert']
-     }),
--    modulus: 'D456320AFB20D3827093DC2C4284ED04DFBABD56E1DDAE529E28B790CD42' +
--              '56DB273349F3735FFD337C7A6363ECCA5A27B7F73DC7089A96C6D886DB0C' +
--              '62388F1CDD6A963AFCD599D5800E587A11F908960F84ED50BA25A28303EC' +
--              'DA6E684FBE7BAEDC9CE8801327B1697AF25097CEE3F175E400984C0DB6A8' +
--              'EB87BE03B4CF94774BA56FFFC8C63C68D6ADEB60ABBE69A7B14AB6A6B9E7' +
--              'BAA89B5ADAB8EB07897C07F6D4FA3D660DFF574107D28E8F63467A788624' +
--              'C574197693E959CEA1362FFAE1BBA10C8C0D88840ABFEF103631B2E8F5C3' +
--              '9B5548A7EA57E8A39F89291813F45A76C448033A2B7ED8403F4BAA147CF3' +
--              '5E2D2554AA65CE49695797095BF4DC6B',
-+    modulusPattern: new RegExp(modulusOSSL, 'i'),
-     bits: 2048,
-     exponent: '0x10001',
-     valid_from: 'Sep  3 21:40:37 2022 GMT',
-@@ -298,7 +300,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
-       '51:62:18:39:E2:E2:77:F5:86:11:E8:C0:CA:54:43:7C:76:83:19:05:D0:03:' +
-       '24:21:B8:EB:14:61:FB:24:16:EB:BD:51:1A:17:91:04:30:03:EB:68:5F:DC:' +
-       '86:E1:D1:7C:FB:AF:78:ED:63:5F:29:9C:32:AF:A1:8E:22:96:D1:02',
--    serialNumber: '147D36C1C2F74206DE9FAB5F2226D78ADB00A426'
-+    serialNumberPattern: /147D36C1C2F74206DE9FAB5F2226D78ADB00A426/i
-   };
- 
-   const legacyObject = x509.toLegacyObject();
-@@ -307,7 +309,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
-   assert.deepStrictEqual(legacyObject.subject, legacyObjectCheck.subject);
-   assert.deepStrictEqual(legacyObject.issuer, legacyObjectCheck.issuer);
-   assert.deepStrictEqual(legacyObject.infoAccess, legacyObjectCheck.infoAccess);
--  assert.strictEqual(legacyObject.modulus, legacyObjectCheck.modulus);
-+  assert.match(legacyObject.modulus, legacyObjectCheck.modulusPattern);
-   assert.strictEqual(legacyObject.bits, legacyObjectCheck.bits);
-   assert.strictEqual(legacyObject.exponent, legacyObjectCheck.exponent);
-   assert.strictEqual(legacyObject.valid_from, legacyObjectCheck.valid_from);
-@@ -316,11 +318,12 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
+@@ -96,8 +96,10 @@ const der = Buffer.from(
+   assert.strictEqual(x509.infoAccess, infoAccessCheck);
+   assert.strictEqual(x509.validFrom, 'Sep  3 21:40:37 2022 GMT');
+   assert.strictEqual(x509.validTo, 'Jun 17 21:40:37 2296 GMT');
++  if (!common.openSSLIsBoringSSL) {
+   assert.deepStrictEqual(x509.validFromDate, new Date('2022-09-03T21:40:37Z'));
+   assert.deepStrictEqual(x509.validToDate, new Date('2296-06-17T21:40:37Z'));
++  }
    assert.strictEqual(
-     legacyObject.fingerprint256,
-     legacyObjectCheck.fingerprint256);
--  assert.strictEqual(
-+  assert.match(
-     legacyObject.serialNumber,
--    legacyObjectCheck.serialNumber);
-+    legacyObjectCheck.serialNumberPattern);
+     x509.fingerprint,
+     '8B:89:16:C4:99:87:D2:13:1A:64:94:36:38:A5:32:01:F0:95:3B:53');
+@@ -325,6 +327,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
+     legacyObjectCheck.serialNumberPattern);
  }
  
-+/*
++if (!common.openSSLIsBoringSSL) {
  {
    // This X.509 Certificate can be parsed by OpenSSL because it contains a
    // structurally sound TBSCertificate structure. However, the SPKI field of the
-@@ -359,3 +362,4 @@ UcXd/5qu2GhokrKU2cPttU+XAN2Om6a0
+@@ -363,6 +366,7 @@ UcXd/5qu2GhokrKU2cPttU+XAN2Om6a0
  
    assert.strictEqual(cert.checkIssued(cert), false);
  }
-+*/
++}
+ 
+ {
+   // Test date parsing of `validFromDate` and `validToDate` fields, according to RFC 5280.
+@@ -400,8 +404,10 @@ UidvpWWipVLZgK+oDks+bKTobcoXGW9oXobiIYqslXPy
+ -----END CERTIFICATE-----`.trim();
+   const c1 = new X509Certificate(certPemUTCTime);
+ 
++  if (!common.openSSLIsBoringSSL) {
+   assert.deepStrictEqual(c1.validFromDate, new Date('1949-12-25T23:59:58Z'));
+   assert.deepStrictEqual(c1.validToDate, new Date('1950-01-01T23:59:58Z'));
++  }
+ 
+   // The GeneralizedTime format is used for dates in 2050 or later.
+   const certPemGeneralizedTime = `-----BEGIN CERTIFICATE-----
+@@ -435,6 +441,8 @@ CWwQO8JZjJqFtqtuzy2n+gLCvqePgG/gmSqHOPm2ZbLW
+ -----END CERTIFICATE-----`.trim();
+   const c2 = new X509Certificate(certPemGeneralizedTime);
+ 
++  if (!common.openSSLIsBoringSSL) {
+   assert.deepStrictEqual(c2.validFromDate, new Date('2049-12-26T00:00:01Z'));
+   assert.deepStrictEqual(c2.validToDate, new Date('2050-01-02T00:00:01Z'));
++  }
+ }
 diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js
-index 4271121881379b6c6892e89e520345f77e4181df..6c87a1ac687aa37d4ba245d1b6fc746a5f1eeffc 100644
+index 4271121881379b6c6892e89e520345f77e4181df..7a17285deee18ffbccf1d01d9d1b7b87e561bffa 100644
 --- a/test/parallel/test-crypto.js
 +++ b/test/parallel/test-crypto.js
 @@ -61,7 +61,7 @@ assert.throws(() => {
@@ -595,23 +530,14 @@ index 4271121881379b6c6892e89e520345f77e4181df..6c87a1ac687aa37d4ba245d1b6fc746a
  validateList(crypto.getHashes());
  // Make sure all of the hashes are supported by OpenSSL
  for (const algo of crypto.getHashes())
-@@ -195,7 +193,7 @@ assert.throws(
-     return true;
+@@ -196,6 +194,7 @@ assert.throws(
    }
  );
--
-+/*
+ 
++if (!common.openSSLIsBoringSSL) {
  assert.throws(() => {
    const priv = [
      '-----BEGIN RSA PRIVATE KEY-----',
-@@ -208,6 +206,7 @@ assert.throws(() => {
-   ].join('\n');
-   crypto.createSign('SHA256').update('test').sign(priv);
- }, (err) => {
-+  console.log(err)
-   if (!common.hasOpenSSL3)
-     assert.ok(!('opensslErrorStack' in err));
-   assert.throws(() => { throw err; }, common.hasOpenSSL3 ? {
 @@ -216,10 +215,10 @@ assert.throws(() => {
      library: 'rsa routines',
    } : {
@@ -632,7 +558,7 @@ index 4271121881379b6c6892e89e520345f77e4181df..6c87a1ac687aa37d4ba245d1b6fc746a
    });
  }
 -
-+*/
++}
  // Make sure memory isn't released before being returned
  console.log(crypto.randomBytes(16));
  
@@ -659,7 +585,7 @@ index 543ee176fb6af38874fee9f14be76f3fdda11060..fef9f1bc2f9fc6c220cf47847e86e038
  }
  
 diff --git a/test/parallel/test-https-agent-session-eviction.js b/test/parallel/test-https-agent-session-eviction.js
-index da5600710560b22049eba1ef18bbb742d447a673..8917b96f666de916616af2fb3ce3a58d00af7438 100644
+index e0986e53c1103b63cf15002a7fa4ce8bc4844d90..33c8a2aa72c56dd4a98558aab2102f03fae2b3cf 100644
 --- a/test/parallel/test-https-agent-session-eviction.js
 +++ b/test/parallel/test-https-agent-session-eviction.js
 @@ -14,7 +14,7 @@ const options = {
@@ -671,35 +597,8 @@ index da5600710560b22049eba1ef18bbb742d447a673..8917b96f666de916616af2fb3ce3a58d
  };
  
  // Create TLS1.2 server
-diff --git a/test/parallel/test-tls-getcertificate-x509.js b/test/parallel/test-tls-getcertificate-x509.js
-index aa685ca9e09cf0d17ff4d5480089e9977dd51f72..ccafa427433922155c1afd5d95ba69d8108825ef 100644
---- a/test/parallel/test-tls-getcertificate-x509.js
-+++ b/test/parallel/test-tls-getcertificate-x509.js
-@@ -20,9 +20,7 @@ const server = tls.createServer(options, function(cleartext) {
- server.once('secureConnection', common.mustCall(function(socket) {
-   const cert = socket.getX509Certificate();
-   assert(cert instanceof X509Certificate);
--  assert.strictEqual(
--    cert.serialNumber,
--    '5B75D77EDC7FB5B7FA9F1424DA4C64FB815DCBDE');
-+  assert.match(cert.serialNumber, /5B75D77EDC7FB5B7FA9F1424DA4C64FB815DCBDE/i)
- }));
- 
- server.listen(0, common.mustCall(function() {
-@@ -33,10 +31,7 @@ server.listen(0, common.mustCall(function() {
-     const peerCert = socket.getPeerX509Certificate();
-     assert(peerCert.issuerCertificate instanceof X509Certificate);
-     assert.strictEqual(peerCert.issuerCertificate.issuerCertificate, undefined);
--    assert.strictEqual(
--      peerCert.issuerCertificate.serialNumber,
--      '147D36C1C2F74206DE9FAB5F2226D78ADB00A425'
--    );
-+    assert.match(peerCert.issuerCertificate.serialNumber, /147D36C1C2F74206DE9FAB5F2226D78ADB00A425/i);
-     server.close();
-   }));
-   socket.end('Hello');
 diff --git a/test/parallel/test-tls-getprotocol.js b/test/parallel/test-tls-getprotocol.js
-index 571f400cea574662bda6be8eecd22ceccaf75420..2296362dc625ee663df11927297ccf124233a19b 100644
+index a9c8775e2f112f2b5e1f4e80f22264f219bf6a9d..4550d28125379e6043962826b8e97b692d63804b 100644
 --- a/test/parallel/test-tls-getprotocol.js
 +++ b/test/parallel/test-tls-getprotocol.js
 @@ -27,7 +27,7 @@ const clientConfigs = [
@@ -725,7 +624,7 @@ index b06f2fa2c53ea72f9a66f0d002dd9281d0259a0f..864fffeebfad75d95416fd47efdea7f2
  
  const server = https.createServer(opts, (req, res) => {
 diff --git a/test/parallel/test-webcrypto-derivebits.js b/test/parallel/test-webcrypto-derivebits.js
-index eb09bc24f0cb8244b05987e3a7c1d203360d3a38..011990db171faa708c5211f6ab9ae1ac0e0ab90e 100644
+index eb09bc24f0cb8244b05987e3a7c1d203360d3a38..8c251ff2371fb59bf679160574e1c5dc1b4b2665 100644
 --- a/test/parallel/test-webcrypto-derivebits.js
 +++ b/test/parallel/test-webcrypto-derivebits.js
 @@ -101,8 +101,9 @@ const { subtle } = globalThis.crypto;
@@ -739,11 +638,6 @@ index eb09bc24f0cb8244b05987e3a7c1d203360d3a38..011990db171faa708c5211f6ab9ae1ac
    async function test(name) {
      const [alice, bob] = await Promise.all([
        subtle.generateKey({ name }, true, ['deriveBits']),
-@@ -126,3 +127,4 @@ const { subtle } = globalThis.crypto;
-   test('X25519').then(common.mustCall());
-   test('X448').then(common.mustCall());
- }
-+
 diff --git a/test/parallel/test-webcrypto-derivekey.js b/test/parallel/test-webcrypto-derivekey.js
 index 558d37d90d5796b30101d1b512c9df3e7661d0db..f42bf8f4be0b439dd7e7c8d0f6f8a41e01588870 100644
 --- a/test/parallel/test-webcrypto-derivekey.js

+ 6 - 6
patches/node/fix_do_not_resolve_electron_entrypoints.patch

@@ -6,10 +6,10 @@ Subject: fix: do not resolve electron entrypoints
 This wastes fs cycles and can result in strange behavior if this path actually exists on disk
 
 diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
-index 463e76cb1abc0c2fdddba4db2ca2e00f7c591e12..d7bc3c35c77b5bf9ec122b38248d0cf1f4d2a548 100644
+index c9d4a3536d0f60375ae623b48ca2fa7095c88d42..d818320fbbc430d06a0c2852e4723981d6e1a844 100644
 --- a/lib/internal/modules/esm/load.js
 +++ b/lib/internal/modules/esm/load.js
-@@ -111,7 +111,7 @@ async function defaultLoad(url, context = kEmptyObject) {
+@@ -109,7 +109,7 @@ async function defaultLoad(url, context = kEmptyObject) {
      source = null;
      format ??= 'builtin';
    } else if (format !== 'commonjs' || defaultType === 'module') {
@@ -19,10 +19,10 @@ index 463e76cb1abc0c2fdddba4db2ca2e00f7c591e12..d7bc3c35c77b5bf9ec122b38248d0cf1
        context = { __proto__: context, source };
      }
 diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
-index 06b31af80ebbfbf35ec787a94f345775eb512ebf..deca5aa4b8829ba9921440fcb5c285a10e40c8f0 100644
+index 0f138b1099b4833176e8a0ce681c745422efc24a..c7dd203e4bd5d611186300d9c0f2255afdf81684 100644
 --- a/lib/internal/modules/esm/translators.js
 +++ b/lib/internal/modules/esm/translators.js
-@@ -354,6 +354,9 @@ function cjsPreparseModuleExports(filename, source) {
+@@ -287,6 +287,9 @@ function cjsPreparseModuleExports(filename, source) {
    if (module && module[kModuleExportNames] !== undefined) {
      return { module, exportNames: module[kModuleExportNames] };
    }
@@ -33,7 +33,7 @@ index 06b31af80ebbfbf35ec787a94f345775eb512ebf..deca5aa4b8829ba9921440fcb5c285a1
    if (!loaded) {
      module = new CJSModule(filename);
 diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
-index 1e1a1ea46fc6c1b43cad4038ab0d9cdf21d6ba3d..95e2fa5479ea31559fdb5a2e03515f243b231b75 100644
+index ab4783a7982b9feb8fa85b62e3e3b181f93309bd..34f91026451d7347ae278712d083e4fe281e50f3 100644
 --- a/lib/internal/modules/run_main.js
 +++ b/lib/internal/modules/run_main.js
 @@ -2,6 +2,7 @@
@@ -58,7 +58,7 @@ index 1e1a1ea46fc6c1b43cad4038ab0d9cdf21d6ba3d..95e2fa5479ea31559fdb5a2e03515f24
    const defaultType = getOptionValue('--experimental-default-type');
    /** @type {string} */
    let mainPath;
-@@ -63,6 +71,13 @@ function resolveMainPath(main) {
+@@ -62,6 +70,13 @@ function resolveMainPath(main) {
   * @param {string} mainPath - Absolute path to the main entry point
   */
  function shouldUseESMLoader(mainPath) {

+ 13 - 13
patches/node/fix_expose_the_built-in_electron_module_via_the_esm_loader.patch

@@ -6,7 +6,7 @@ Subject: fix: expose the built-in electron module via the ESM loader
 This allows usage of `import { app } from 'electron'` and `import('electron')` natively in the browser + non-sandboxed renderer
 
 diff --git a/lib/internal/modules/esm/get_format.js b/lib/internal/modules/esm/get_format.js
-index a89446df710a941390c15171fea63c551776fc93..912f03bfa96c3aa12bfa6e709746642452568bb7 100644
+index 9519f947b8dfdc69808839948c9cb8434a0acf0e..23ce72d479f638c33edffcea7c35f5da6cab7cae 100644
 --- a/lib/internal/modules/esm/get_format.js
 +++ b/lib/internal/modules/esm/get_format.js
 @@ -26,6 +26,7 @@ const protocolHandlers = {
@@ -18,10 +18,10 @@ index a89446df710a941390c15171fea63c551776fc93..912f03bfa96c3aa12bfa6e7097466424
  
  /**
 diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
-index 8b157f0f461c7b92c567fffe4d99357dbc09aee7..605e812d515fc467001e4ab88fc15b4af3fd4aa2 100644
+index 5ba13096b98047ff33e4d44167c2a069ccc5e69d..a00b5979e3b5deb4ba315b4635c7e5d2801c376e 100644
 --- a/lib/internal/modules/esm/load.js
 +++ b/lib/internal/modules/esm/load.js
-@@ -121,7 +121,7 @@ async function defaultLoad(url, context = kEmptyObject) {
+@@ -119,7 +119,7 @@ async function defaultLoad(url, context = kEmptyObject) {
        // Now that we have the source for the module, run `defaultGetFormat` to detect its format.
        format = await defaultGetFormat(urlInstance, context);
  
@@ -30,7 +30,7 @@ index 8b157f0f461c7b92c567fffe4d99357dbc09aee7..605e812d515fc467001e4ab88fc15b4a
          // For backward compatibility reasons, we need to discard the source in
          // order for the CJS loader to re-fetch it.
          source = null;
-@@ -218,12 +218,13 @@ function throwIfUnsupportedURLScheme(parsed) {
+@@ -200,12 +200,13 @@ function throwIfUnsupportedURLScheme(parsed) {
      protocol !== 'file:' &&
      protocol !== 'data:' &&
      protocol !== 'node:' &&
@@ -46,10 +46,10 @@ index 8b157f0f461c7b92c567fffe4d99357dbc09aee7..605e812d515fc467001e4ab88fc15b4a
    }
  }
 diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
-index 1fbbb6773c9479128408fa1f27cf19f1a7786ba6..f05c6f99c0037193c5802024be46a967d6cf47a0 100644
+index 61c043e35c6ce9ef9d7255e009162289e80eaf4d..0c41492aa9652112df0b839361570a832daf3b13 100644
 --- a/lib/internal/modules/esm/resolve.js
 +++ b/lib/internal/modules/esm/resolve.js
-@@ -772,6 +772,8 @@ function parsePackageName(specifier, base) {
+@@ -791,6 +791,8 @@ function parsePackageName(specifier, base) {
    return { packageName, packageSubpath, isScoped };
  }
  
@@ -58,7 +58,7 @@ index 1fbbb6773c9479128408fa1f27cf19f1a7786ba6..f05c6f99c0037193c5802024be46a967
  /**
   * Resolves a package specifier to a URL.
   * @param {string} specifier - The package specifier to resolve.
-@@ -785,6 +787,11 @@ function packageResolve(specifier, base, conditions) {
+@@ -804,6 +806,11 @@ function packageResolve(specifier, base, conditions) {
      return new URL('node:' + specifier);
    }
  
@@ -71,10 +71,10 @@ index 1fbbb6773c9479128408fa1f27cf19f1a7786ba6..f05c6f99c0037193c5802024be46a967
      parsePackageName(specifier, base);
  
 diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
-index 8f88214f558c52ef26000fb0e1ef4d391327e84e..d182eedf5e96039e0029d36e51f40b75c6fb2a39 100644
+index 491dc3f450733a9181096a145cfa508767682658..23ed971daebdda3cb627907ffa3626daaa5b5b7b 100644
 --- a/lib/internal/modules/esm/translators.js
 +++ b/lib/internal/modules/esm/translators.js
-@@ -246,7 +246,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
+@@ -182,7 +182,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
  
    const { exportNames, module } = cjsPreparseModuleExports(filename, source);
    cjsCache.set(url, module);
@@ -83,7 +83,7 @@ index 8f88214f558c52ef26000fb0e1ef4d391327e84e..d182eedf5e96039e0029d36e51f40b75
      [...exportNames] : ['default', ...exportNames];
  
    if (isMain) {
-@@ -268,8 +268,8 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
+@@ -204,8 +204,8 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
        ({ exports } = module);
      }
      for (const exportName of exportNames) {
@@ -94,7 +94,7 @@ index 8f88214f558c52ef26000fb0e1ef4d391327e84e..d182eedf5e96039e0029d36e51f40b75
          continue;
        }
        // We might trigger a getter -> dont fail.
-@@ -304,6 +304,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
+@@ -239,6 +239,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
    return createCJSModuleWrap(url, source);
  });
  
@@ -106,10 +106,10 @@ index 8f88214f558c52ef26000fb0e1ef4d391327e84e..d182eedf5e96039e0029d36e51f40b75
  // This translator function must be sync, as `require` is sync.
  translators.set('require-commonjs-typescript', (url, source, isMain) => {
 diff --git a/lib/internal/url.js b/lib/internal/url.js
-index 3cb186182947a14407e9d5c4d94ab0554298a658..e35ae9ac316ba2e5b8f562d353b2c5ae978abb63 100644
+index 14b0ef61d2f91cf48bba9aceefc55751e7ed5db2..6d6b32f65131d1d55aeeae27dd2970440d99b4bd 100644
 --- a/lib/internal/url.js
 +++ b/lib/internal/url.js
-@@ -1495,6 +1495,8 @@ function fileURLToPath(path, options = kEmptyObject) {
+@@ -1505,6 +1505,8 @@ function fileURLToPath(path, options = kEmptyObject) {
      path = new URL(path);
    else if (!isURL(path))
      throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path);

+ 71 - 83
patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch

@@ -17,15 +17,10 @@ Upstreams:
 - https://github.com/nodejs/node/pull/39136
 
 diff --git a/deps/ncrypto/ncrypto.cc b/deps/ncrypto/ncrypto.cc
-index eb3533bb4623b152605c3c590f37f086cce5f073..ded231aeaa15af22845704cfcc7d24a44bd88f8e 100644
+index ac2d771555126a4f43b8c3a3fd299d40019e6622..769fe636ef2b5d02ecc9ff753e64d93ea5075700 100644
 --- a/deps/ncrypto/ncrypto.cc
 +++ b/deps/ncrypto/ncrypto.cc
-@@ -6,13 +6,11 @@
- #include <openssl/evp.h>
- #include <openssl/hmac.h>
- #include <openssl/pkcs12.h>
-+#include <openssl/rand.h>
- #include <openssl/x509v3.h>
+@@ -11,9 +11,6 @@
  #if OPENSSL_VERSION_MAJOR >= 3
  #include <openssl/provider.h>
  #endif
@@ -35,7 +30,7 @@ index eb3533bb4623b152605c3c590f37f086cce5f073..ded231aeaa15af22845704cfcc7d24a4
  
  namespace ncrypto {
  namespace {
-@@ -665,7 +663,7 @@ bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) {
+@@ -708,7 +705,7 @@ bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext) {
  
    bool ok = true;
  
@@ -43,8 +38,8 @@ index eb3533bb4623b152605c3c590f37f086cce5f073..ded231aeaa15af22845704cfcc7d24a4
 +  for (size_t i = 0; i < sk_GENERAL_NAME_num(names); i++) {
      GENERAL_NAME* gen = sk_GENERAL_NAME_value(names, i);
  
-     if (i != 0)
-@@ -691,7 +689,7 @@ bool SafeX509InfoAccessPrint(const BIOPointer& out, X509_EXTENSION* ext) {
+     if (i != 0) BIO_write(out.get(), ", ", 2);
+@@ -732,7 +729,7 @@ bool SafeX509InfoAccessPrint(const BIOPointer& out, X509_EXTENSION* ext) {
  
    bool ok = true;
  
@@ -52,22 +47,42 @@ index eb3533bb4623b152605c3c590f37f086cce5f073..ded231aeaa15af22845704cfcc7d24a4
 +  for (size_t i = 0; i < sk_ACCESS_DESCRIPTION_num(descs); i++) {
      ACCESS_DESCRIPTION* desc = sk_ACCESS_DESCRIPTION_value(descs, i);
  
-     if (i != 0)
-@@ -1002,7 +1000,11 @@ BIOPointer BIOPointer::NewMem() {
+     if (i != 0) BIO_write(out.get(), "\n", 1);
+@@ -874,13 +871,17 @@ BIOPointer X509View::getValidTo() const {
+ 
+ int64_t X509View::getValidToTime() const {
+   struct tm tp;
+-  ASN1_TIME_to_tm(X509_get0_notAfter(cert_), &tp);
++#ifndef OPENSSL_IS_BORINGSSL
++   ASN1_TIME_to_tm(X509_get0_notAfter(cert_), &tp);
++#endif
+   return PortableTimeGM(&tp);
+ }
+ 
+ int64_t X509View::getValidFromTime() const {
+   struct tm tp;
++#ifndef OPENSSL_IS_BORINGSSL
+   ASN1_TIME_to_tm(X509_get0_notBefore(cert_), &tp);
++#endif
+   return PortableTimeGM(&tp);
+ }
+ 
+@@ -1085,7 +1086,11 @@ BIOPointer BIOPointer::NewMem() {
  }
  
  BIOPointer BIOPointer::NewSecMem() {
+-  return BIOPointer(BIO_new(BIO_s_secmem()));
 +#ifdef OPENSSL_IS_BORINGSSL
 +  return BIOPointer(BIO_new(BIO_s_mem()));
 +#else
-   return BIOPointer(BIO_new(BIO_s_secmem()));
++   return BIOPointer(BIO_new(BIO_s_secmem()));
 +#endif
  }
  
  BIOPointer BIOPointer::New(const BIO_METHOD* method) {
-@@ -1057,8 +1059,10 @@ BignumPointer DHPointer::FindGroup(const std::string_view name,
-                                    FindGroupOption option) {
- #define V(n, p) if (EqualNoCase(name, n)) return BignumPointer(p(nullptr));
+@@ -1149,8 +1154,10 @@ BignumPointer DHPointer::FindGroup(const std::string_view name,
+ #define V(n, p)                                                                \
+   if (EqualNoCase(name, n)) return BignumPointer(p(nullptr));
    if (option != FindGroupOption::NO_SMALL_PRIMES) {
 +#ifndef OPENSSL_IS_BORINGSSL
      V("modp1", BN_get_rfc2409_prime_768);
@@ -76,7 +91,7 @@ index eb3533bb4623b152605c3c590f37f086cce5f073..ded231aeaa15af22845704cfcc7d24a4
      V("modp5", BN_get_rfc3526_prime_1536);
    }
    V("modp14", BN_get_rfc3526_prime_2048);
-@@ -1130,11 +1134,13 @@ DHPointer::CheckPublicKeyResult DHPointer::checkPublicKey(const BignumPointer& p
+@@ -1223,11 +1230,13 @@ DHPointer::CheckPublicKeyResult DHPointer::checkPublicKey(
    int codes = 0;
    if (DH_check_pub_key(dh_.get(), pub_key.get(), &codes) != 1)
      return DHPointer::CheckPublicKeyResult::CHECK_FAILED;
@@ -92,10 +107,10 @@ index eb3533bb4623b152605c3c590f37f086cce5f073..ded231aeaa15af22845704cfcc7d24a4
    }
    return CheckPublicKeyResult::NONE;
 diff --git a/deps/ncrypto/ncrypto.h b/deps/ncrypto/ncrypto.h
-index 60bfce3ea8999e8e145aaf8cd14f0fdf21ed9c54..55aae783bb57273d1b49927f65b6c0830d09d115 100644
+index fffa75ec718facc61cebf48f33ddc3909b9b9413..19757016a4f50e2f656a76bf60cb87e601845afe 100644
 --- a/deps/ncrypto/ncrypto.h
 +++ b/deps/ncrypto/ncrypto.h
-@@ -400,17 +400,21 @@ public:
+@@ -516,17 +516,21 @@ class DHPointer final {
      UNABLE_TO_CHECK_GENERATOR = DH_UNABLE_TO_CHECK_GENERATOR,
      NOT_SUITABLE_GENERATOR = DH_NOT_SUITABLE_GENERATOR,
      Q_NOT_PRIME = DH_CHECK_Q_NOT_PRIME,
@@ -118,36 +133,24 @@ index 60bfce3ea8999e8e145aaf8cd14f0fdf21ed9c54..55aae783bb57273d1b49927f65b6c083
      CHECK_FAILED = 512,
    };
    // Check to see if the given public key is suitable for this DH instance.
-diff --git a/deps/ncrypto/unofficial.gni b/deps/ncrypto/unofficial.gni
-index ea024af73e215b3cad5f08796ac405f419530c86..41061b524eea74330b8d2452635a38c48f21386b 100644
---- a/deps/ncrypto/unofficial.gni
-+++ b/deps/ncrypto/unofficial.gni
-@@ -27,6 +27,6 @@ template("ncrypto_gn_build") {
-     forward_variables_from(invoker, "*")
-     public_configs = [ ":ncrypto_config" ]
-     sources = gypi_values.ncrypto_sources
--    deps = [ "../openssl" ]
-+    deps = [ "$node_crypto_path" ]
-   }
- }
 diff --git a/node.gni b/node.gni
-index 32709b860ccb12d8d1e75342a65dda0b86129b21..18d58591e3d0f1f3512db00033c3410a65702864 100644
+index 245a43920c7baf000ba63192a84a4c3fd219be7d..56a554175b805c1703f13d62041f8c80d6e94dd9 100644
 --- a/node.gni
 +++ b/node.gni
-@@ -10,6 +10,8 @@ declare_args() {
-   # The location of V8, use the one from node's deps by default.
+@@ -11,7 +11,7 @@ declare_args() {
    node_v8_path = "//v8"
  
-+  node_crypto_path = "//third_party/boringssl"
-+
-   # The NODE_MODULE_VERSION defined in node_version.h.
-   node_module_version = exec_script("$node_path/tools/getmoduleversion.py", [], "value")
+   # The location of OpenSSL - use the one from node's deps by default.
+-  node_openssl_path = "$node_path/deps/openssl"
++  node_openssl_path = "//third_party/boringssl"
  
+   # The location of simdutf - use the one from node's deps by default.
+   node_simdutf_path = "$node_path/deps/simdutf"
 diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc
-index fe35a8e0f6bbb7ab515a0343a7ed046c44e86474..43a7abbf237d8d809953e302b83755a3283a1bf4 100644
+index c7588583530cf291946d01cec807390d987706cf..495fb92355a7eadc2f7ec885a3b529988bb3bd02 100644
 --- a/src/crypto/crypto_cipher.cc
 +++ b/src/crypto/crypto_cipher.cc
-@@ -1078,7 +1078,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
+@@ -1080,7 +1080,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
      if (EVP_PKEY_decrypt_init(ctx.get()) <= 0) {
        return ThrowCryptoError(env, ERR_get_error());
      }
@@ -156,16 +159,16 @@ index fe35a8e0f6bbb7ab515a0343a7ed046c44e86474..43a7abbf237d8d809953e302b83755a3
      int rsa_pkcs1_implicit_rejection =
          EVP_PKEY_CTX_ctrl_str(ctx.get(), "rsa_pkcs1_implicit_rejection", "1");
      // From the doc -2 means that the option is not supported.
-@@ -1094,6 +1094,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
-           "RSA_PKCS1_PADDING is no longer supported for private decryption,"
-           " this can be reverted with --security-revert=CVE-2024-PEND");
+@@ -1095,6 +1095,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
+           env,
+           "RSA_PKCS1_PADDING is no longer supported for private decryption");
      }
 +#endif
    }
  
    const EVP_MD* digest = nullptr;
 diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc
-index 6a967702b22df0eb8aa10e853fd232794955860d..31058cccc6ffeed6b09aaecda320ee2f15849ec8 100644
+index 43a126f863779d3f364f92bd237039474b489845..77a3caee93049f65faef37e93b871c467ebca7e5 100644
 --- a/src/crypto/crypto_common.cc
 +++ b/src/crypto/crypto_common.cc
 @@ -134,7 +134,7 @@ const char* GetClientHelloALPN(const SSLPointer& ssl) {
@@ -254,7 +257,7 @@ index 6a967702b22df0eb8aa10e853fd232794955860d..31058cccc6ffeed6b09aaecda320ee2f
    crypto::EVPKeyPointer key(raw_key);
  
 diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc
-index c924a54639e8c22d765dc240dffacfffb200ca0c..287afcc792a0a2b7e19126ee9a48ebe21cc8844e 100644
+index aa5fc61f19e435b4833f3f49df10fa1edf2142c7..0a338b018a4ec20cb5bce250faf60d3f3bf192d4 100644
 --- a/src/crypto/crypto_context.cc
 +++ b/src/crypto/crypto_context.cc
 @@ -94,7 +94,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
@@ -290,7 +293,7 @@ index c924a54639e8c22d765dc240dffacfffb200ca0c..287afcc792a0a2b7e19126ee9a48ebe2
  
      X509_STORE_add_cert(sc->GetCertStoreOwnedByThisSecureContext(), ca);
 diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc
-index e5664dfa2bc7e11922fa965f28acdf21470d1147..33ffbbb85d05f5356183e3aa1ca23707c5629b5d 100644
+index d760a0d3ea1d12184a558f5e87cb22043d26a0f5..f973941b3b9ea954f35f2ea135f8ee3d77b98958 100644
 --- a/src/crypto/crypto_dh.cc
 +++ b/src/crypto/crypto_dh.cc
 @@ -7,7 +7,9 @@
@@ -375,7 +378,7 @@ index e5664dfa2bc7e11922fa965f28acdf21470d1147..33ffbbb85d05f5356183e3aa1ca23707
        break;
    }
 @@ -398,9 +398,11 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
-     key_params = EVPKeyPointer(EVP_PKEY_new());
+     key_params = EVPKeyPointer::New();
      CHECK(key_params);
      CHECK_EQ(EVP_PKEY_assign_DH(key_params.get(), dh.release()), 1);
 -  } else if (int* prime_size = std::get_if<int>(&params->params.prime)) {
@@ -398,7 +401,7 @@ index e5664dfa2bc7e11922fa965f28acdf21470d1147..33ffbbb85d05f5356183e3aa1ca23707
      UNREACHABLE();
    }
 diff --git a/src/crypto/crypto_dsa.cc b/src/crypto/crypto_dsa.cc
-index 5d081863cf2dcdcf8c2d09db6060eeb5e78c452f..67523ec1c406e345945e1dde663c784c43a1c624 100644
+index b557de774117e442d7f429e92d63a6e1faa236fd..0aca233ced39269b09c383e5b32d85cf36260a1e 100644
 --- a/src/crypto/crypto_dsa.cc
 +++ b/src/crypto/crypto_dsa.cc
 @@ -40,7 +40,7 @@ namespace crypto {
@@ -422,10 +425,10 @@ index 5d081863cf2dcdcf8c2d09db6060eeb5e78c452f..67523ec1c406e345945e1dde663c784c
      return EVPKeyCtxPointer();
  
 diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc
-index 8488fc57faaf722174032c5a927d150c76120d60..c51efc92d4818ee7701b4725585fb7e1d2d644ad 100644
+index ac4103400e1e293909e7c524f4a1422c5f04e707..c44c11cbd533350d8bf149032c658d5585303b7d 100644
 --- a/src/crypto/crypto_keys.cc
 +++ b/src/crypto/crypto_keys.cc
-@@ -1204,6 +1204,7 @@ void KeyObjectHandle::GetAsymmetricKeyType(
+@@ -945,6 +945,7 @@ void KeyObjectHandle::GetAsymmetricKeyType(
  }
  
  bool KeyObjectHandle::CheckEcKeyData() const {
@@ -433,7 +436,7 @@ index 8488fc57faaf722174032c5a927d150c76120d60..c51efc92d4818ee7701b4725585fb7e1
    MarkPopErrorOnReturn mark_pop_error_on_return;
  
    const auto& key = data_.GetAsymmetricKey();
-@@ -1220,6 +1221,9 @@ bool KeyObjectHandle::CheckEcKeyData() const {
+@@ -961,6 +962,9 @@ bool KeyObjectHandle::CheckEcKeyData() const {
  #else
    return EVP_PKEY_public_check(ctx.get()) == 1;
  #endif
@@ -457,27 +460,25 @@ index b59e394d9a7e2c19fdf1f2b0177753ff488da0fa..91218f49da5392c6f769495ee7f9275a
      THROW_ERR_CRYPTO_OPERATION_FAILED(env, "could not generate prime");
      return Nothing<void>();
 diff --git a/src/crypto/crypto_rsa.cc b/src/crypto/crypto_rsa.cc
-index 02e8e24b4054afd4c3ca797c19a78927319a0d9e..d2a931a3f8f9490fe17ef8a82d0204ee2cca409d 100644
+index 6d360554b31d53a597d61fcbd660f703a903ca21..86fafe98222d4c18f062032d80104f3ef00dbc01 100644
 --- a/src/crypto/crypto_rsa.cc
 +++ b/src/crypto/crypto_rsa.cc
-@@ -608,10 +608,11 @@ Maybe<void> GetRsaKeyDetail(Environment* env,
+@@ -608,10 +608,13 @@ Maybe<void> GetRsaKeyDetail(Environment* env,
        }
  
        if (params->saltLength != nullptr) {
--        if (ASN1_INTEGER_get_int64(&salt_length, params->saltLength) != 1) {
--          ThrowCryptoError(env, ERR_get_error(), "ASN1_INTEGER_get_in64 error");
--          return Nothing<void>();
--        }
++#ifndef OPENSSL_IS_BORINGSSL
 +        // TODO(codebytere): Upstream a shim to BoringSSL?
-+        // if (ASN1_INTEGER_get_int64(&salt_length, params->saltLength) != 1) {
-+        //   ThrowCryptoError(env, ERR_get_error(), "ASN1_INTEGER_get_in64 error");
-+        //   return Nothing<void>();
-+        // }
+         if (ASN1_INTEGER_get_int64(&salt_length, params->saltLength) != 1) {
+           ThrowCryptoError(env, ERR_get_error(), "ASN1_INTEGER_get_in64 error");
+           return Nothing<void>();
+         }
++#endif
        }
  
        if (target
 diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
-index 793c196f8ce538c66b20611d00e12392ff9e878b..ee81048caab4ccfe26ea9e677782c9c955d162a9 100644
+index 12ee0cde0897024bccb0face49053544a0bcfcd7..8a6a36a3c31532ed585c287ba8cee14026d315b4 100644
 --- a/src/crypto/crypto_util.cc
 +++ b/src/crypto/crypto_util.cc
 @@ -495,24 +495,15 @@ Maybe<void> Decorate(Environment* env,
@@ -538,7 +539,7 @@ index 793c196f8ce538c66b20611d00e12392ff9e878b..ee81048caab4ccfe26ea9e677782c9c9
  }  // namespace
  
 diff --git a/src/env.h b/src/env.h
-index fc8dbd615255851cad90e1d8ffe225f5e0c6a718..49ca9c0042ccf22ad1fffa54f05fd443cbc681ba 100644
+index 16312e548e526b80ec9a230bc3c772f45685b61f..0a3f09ebc7e2e7c1f8b9499d4439e2ca90b86810 100644
 --- a/src/env.h
 +++ b/src/env.h
 @@ -50,7 +50,7 @@
@@ -550,7 +551,7 @@ index fc8dbd615255851cad90e1d8ffe225f5e0c6a718..49ca9c0042ccf22ad1fffa54f05fd443
  #include <openssl/evp.h>
  #endif
  
-@@ -1073,7 +1073,7 @@ class Environment final : public MemoryRetainer {
+@@ -1062,7 +1062,7 @@ class Environment final : public MemoryRetainer {
      kExitInfoFieldCount
    };
  
@@ -573,7 +574,7 @@ index c59e65ad1fe3fac23f1fc25ca77e6133d1ccaccd..f2f07434e076e2977755ef7dac7d489a
  #if NODE_OPENSSL_HAS_QUIC
  #include <openssl/quic.h>
 diff --git a/src/node_options.cc b/src/node_options.cc
-index cfc599ec9a6197231c3469d318f02c620cdb03a8..29630fcccc3bd9d24ad6aec64bef2fedfc3c4031 100644
+index a03daec2bd74d7857d38238ea0479e36e054a7a3..f70e0917f6caa66210107cdb2ef891685563ba96 100644
 --- a/src/node_options.cc
 +++ b/src/node_options.cc
 @@ -6,7 +6,7 @@
@@ -586,7 +587,7 @@ index cfc599ec9a6197231c3469d318f02c620cdb03a8..29630fcccc3bd9d24ad6aec64bef2fed
  #endif
  
 diff --git a/src/node_options.h b/src/node_options.h
-index 9e656a2815045aa5da7eb267708c03058be9f362..600e0850f01e01024414d42b25605f256200540a 100644
+index ab6ea77b2e9ce54af44e21c29fcba929f117c41b..23923ccd645e810d84b0a08e57e486d012b5796b 100644
 --- a/src/node_options.h
 +++ b/src/node_options.h
 @@ -11,7 +11,7 @@
@@ -599,10 +600,10 @@ index 9e656a2815045aa5da7eb267708c03058be9f362..600e0850f01e01024414d42b25605f25
  #endif
  
 diff --git a/unofficial.gni b/unofficial.gni
-index de6ff5548ca5282199b7d85c11941c1fa351a9d9..3d8b7957e791ce2fa2a8d0937a87b6010087803d 100644
+index 3632d5bd21e277fcbd8d62dc65598a7f7c87f00e..08a4ed939fb1482a897def94128282fdfd63dc62 100644
 --- a/unofficial.gni
 +++ b/unofficial.gni
-@@ -145,7 +145,6 @@ template("node_gn_build") {
+@@ -151,7 +151,6 @@ template("node_gn_build") {
      ]
      deps = [
        ":run_node_js2c",
@@ -610,25 +611,12 @@ index de6ff5548ca5282199b7d85c11941c1fa351a9d9..3d8b7957e791ce2fa2a8d0937a87b601
        "deps/cares",
        "deps/histogram",
        "deps/llhttp",
-@@ -156,6 +155,8 @@ template("node_gn_build") {
+@@ -161,6 +160,8 @@ template("node_gn_build") {
        "deps/sqlite",
        "deps/uvwasi",
        "//third_party/zlib",
 +      "//third_party/brotli:dec",
 +      "//third_party/brotli:enc",
+       "$node_simdutf_path",
        "$node_v8_path:v8_libplatform",
      ]
- 
-@@ -182,10 +183,8 @@ template("node_gn_build") {
-       deps += [ "//third_party/icu" ]
-     }
-     if (node_use_openssl) {
--      deps += [
--        "deps/ncrypto",
--        "//third_party/boringssl"
--      ]
-+      deps += [ "deps/ncrypto" ]
-+      public_deps += [ "$node_crypto_path" ]
-       sources += gypi_values.node_crypto_sources
-     }
-     if (node_enable_inspector) {

+ 13 - 13
patches/node/fix_lazyload_fs_in_esm_loaders_to_apply_asar_patches.patch

@@ -6,10 +6,10 @@ Subject: fix: lazyload fs in esm loaders to apply asar patches
 Changes { foo } from fs to just "fs.foo" so that our patching of fs is applied to esm loaders
 
 diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
-index 605e812d515fc467001e4ab88fc15b4af3fd4aa2..463e76cb1abc0c2fdddba4db2ca2e00f7c591e12 100644
+index a00b5979e3b5deb4ba315b4635c7e5d2801c376e..c9d4a3536d0f60375ae623b48ca2fa7095c88d42 100644
 --- a/lib/internal/modules/esm/load.js
 +++ b/lib/internal/modules/esm/load.js
-@@ -8,7 +8,7 @@ const { kEmptyObject } = require('internal/util');
+@@ -10,7 +10,7 @@ const {
  const { defaultGetFormat } = require('internal/modules/esm/get_format');
  const { validateAttributes, emitImportAssertionWarning } = require('internal/modules/esm/assert');
  const { getOptionValue } = require('internal/options');
@@ -18,7 +18,7 @@ index 605e812d515fc467001e4ab88fc15b4af3fd4aa2..463e76cb1abc0c2fdddba4db2ca2e00f
  
  const defaultType =
    getOptionValue('--experimental-default-type');
-@@ -40,8 +40,7 @@ async function getSource(url, context) {
+@@ -38,8 +38,7 @@ async function getSource(url, context) {
    const responseURL = href;
    let source;
    if (protocol === 'file:') {
@@ -28,7 +28,7 @@ index 605e812d515fc467001e4ab88fc15b4af3fd4aa2..463e76cb1abc0c2fdddba4db2ca2e00f
    } else if (protocol === 'data:') {
      const result = dataURLProcessor(url);
      if (result === 'failure') {
-@@ -65,7 +64,7 @@ function getSourceSync(url, context) {
+@@ -63,7 +62,7 @@ function getSourceSync(url, context) {
    const responseURL = href;
    let source;
    if (protocol === 'file:') {
@@ -38,11 +38,11 @@ index 605e812d515fc467001e4ab88fc15b4af3fd4aa2..463e76cb1abc0c2fdddba4db2ca2e00f
      const result = dataURLProcessor(url);
      if (result === 'failure') {
 diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
-index f05c6f99c0037193c5802024be46a967d6cf47a0..f3dad958b2ec275992554477b9344214c8c1e2c8 100644
+index 0c41492aa9652112df0b839361570a832daf3b13..f2fbb576da23fc0a48b0c979a263aa2dbe3600eb 100644
 --- a/lib/internal/modules/esm/resolve.js
 +++ b/lib/internal/modules/esm/resolve.js
-@@ -24,7 +24,7 @@ const {
- } = primordials;
+@@ -25,7 +25,7 @@ const {
+ const assert = require('internal/assert');
  const internalFS = require('internal/fs/utils');
  const { BuiltinModule } = require('internal/bootstrap/realm');
 -const { realpathSync } = require('fs');
@@ -50,7 +50,7 @@ index f05c6f99c0037193c5802024be46a967d6cf47a0..f3dad958b2ec275992554477b9344214
  const { getOptionValue } = require('internal/options');
  // Do not eagerly grab .manifest, it may be in TDZ
  const { sep, posix: { relative: relativePosixPath }, resolve } = require('path');
-@@ -259,7 +259,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
+@@ -277,7 +277,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
    }
  
    if (!preserveSymlinks) {
@@ -60,10 +60,10 @@ index f05c6f99c0037193c5802024be46a967d6cf47a0..f3dad958b2ec275992554477b9344214
      });
      const { search, hash } = resolved;
 diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
-index d182eedf5e96039e0029d36e51f40b75c6fb2a39..06b31af80ebbfbf35ec787a94f345775eb512ebf 100644
+index 23ed971daebdda3cb627907ffa3626daaa5b5b7b..0f138b1099b4833176e8a0ce681c745422efc24a 100644
 --- a/lib/internal/modules/esm/translators.js
 +++ b/lib/internal/modules/esm/translators.js
-@@ -34,7 +34,7 @@ const {
+@@ -24,7 +24,7 @@ const {
  
  const { BuiltinModule } = require('internal/bootstrap/realm');
  const assert = require('internal/assert');
@@ -71,8 +71,8 @@ index d182eedf5e96039e0029d36e51f40b75c6fb2a39..06b31af80ebbfbf35ec787a94f345775
 +const fs = require('fs');
  const { dirname, extname, isAbsolute } = require('path');
  const {
-   loadBuiltinModule,
-@@ -335,7 +335,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
+   assertBufferSource,
+@@ -269,7 +269,7 @@ translators.set('commonjs', function commonjsStrategy(url, source, isMain) {
  
    try {
      // We still need to read the FS to detect the exports.
@@ -81,7 +81,7 @@ index d182eedf5e96039e0029d36e51f40b75c6fb2a39..06b31af80ebbfbf35ec787a94f345775
    } catch {
      // Continue regardless of error.
    }
-@@ -403,7 +403,7 @@ function cjsPreparseModuleExports(filename, source) {
+@@ -336,7 +336,7 @@ function cjsPreparseModuleExports(filename, source) {
        isAbsolute(resolved)) {
          // TODO: this should be calling the `load` hook chain to get the source
          // (and fallback to reading the FS only if the source is nullish).

+ 1 - 1
patches/node/fix_remove_deprecated_errno_constants.patch

@@ -10,7 +10,7 @@ This change removes the usage of these constants to fix a compilation failure du
 See: https://github.com/llvm/llvm-project/pull/80542
 
 diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
-index 7f48b7daa87d1a5b14bc6f641b60f21263fa5ec3..0be470c9139a6da19414295a59f1a237cc3a50d7 100644
+index f75a496071ac3396cbc6dec819eaab7294609deb..30f9a05f2f508b55a7d7ae036612660068c8400e 100644
 --- a/deps/uv/include/uv.h
 +++ b/deps/uv/include/uv.h
 @@ -155,7 +155,6 @@ struct uv__queue {

+ 14 - 15
patches/node/fix_remove_fastapitypedarray_usage.patch

@@ -48,7 +48,7 @@ index 867a1c4aca54b9d41490d23a5eb55088b7e941cc..09f4c65a18efea262b1f854f993c6f18
  
  static v8::CFunction fast_equal(v8::CFunction::Make(FastTimingSafeEqual));
 diff --git a/src/node_buffer.cc b/src/node_buffer.cc
-index 2302e8d94da3250e7fb4ee0c5e6a51d3d6941fbc..ed72476e16036d972de54d39cf4bd37bbbed5c5f 100644
+index cd51d9acf9540d506ec35812b9d2c530fce24912..07068344262f7b73a83073d4da75bffe8b747a61 100644
 --- a/src/node_buffer.cc
 +++ b/src/node_buffer.cc
 @@ -44,6 +44,14 @@
@@ -74,7 +74,7 @@ index 2302e8d94da3250e7fb4ee0c5e6a51d3d6941fbc..ed72476e16036d972de54d39cf4bd37b
  using v8::FunctionCallbackInfo;
  using v8::Global;
  using v8::HandleScope;
-@@ -581,19 +588,24 @@ void SlowCopy(const FunctionCallbackInfo<Value>& args) {
+@@ -582,19 +589,24 @@ void SlowCopy(const FunctionCallbackInfo<Value>& args) {
  
  // Assume caller has properly validated args.
  uint32_t FastCopy(Local<Value> receiver,
@@ -107,7 +107,7 @@ index 2302e8d94da3250e7fb4ee0c5e6a51d3d6941fbc..ed72476e16036d972de54d39cf4bd37b
    return to_copy;
  }
  
-@@ -857,19 +869,17 @@ void Compare(const FunctionCallbackInfo<Value> &args) {
+@@ -858,19 +870,17 @@ void Compare(const FunctionCallbackInfo<Value> &args) {
  }
  
  int32_t FastCompare(v8::Local<v8::Value>,
@@ -135,7 +135,7 @@ index 2302e8d94da3250e7fb4ee0c5e6a51d3d6941fbc..ed72476e16036d972de54d39cf4bd37b
  }
  
  static v8::CFunction fast_compare(v8::CFunction::Make(FastCompare));
-@@ -1140,14 +1150,13 @@ void SlowIndexOfNumber(const FunctionCallbackInfo<Value>& args) {
+@@ -1141,14 +1151,13 @@ void SlowIndexOfNumber(const FunctionCallbackInfo<Value>& args) {
  }
  
  int32_t FastIndexOfNumber(v8::Local<v8::Value>,
@@ -153,7 +153,7 @@ index 2302e8d94da3250e7fb4ee0c5e6a51d3d6941fbc..ed72476e16036d972de54d39cf4bd37b
  }
  
  static v8::CFunction fast_index_of_number(
-@@ -1552,21 +1561,31 @@ void SlowWriteString(const FunctionCallbackInfo<Value>& args) {
+@@ -1501,21 +1510,31 @@ void SlowWriteString(const FunctionCallbackInfo<Value>& args) {
  
  template <encoding encoding>
  uint32_t FastWriteString(Local<Value> receiver,
@@ -194,10 +194,10 @@ index 2302e8d94da3250e7fb4ee0c5e6a51d3d6941fbc..ed72476e16036d972de54d39cf4bd37b
  
  static v8::CFunction fast_write_string_ascii(
 diff --git a/src/node_external_reference.h b/src/node_external_reference.h
-index 38a4ff7e6c2c9997f004c7c1f94cb5a9ffc2ffe0..48e73168f994d79ae3564b813acb5546ca8f2526 100644
+index 8d49a119c218323674e29a522ecf71bd22cdaf1b..d39693f2f45f39e45960453112b0f6460a1b3a4d 100644
 --- a/src/node_external_reference.h
 +++ b/src/node_external_reference.h
-@@ -34,16 +34,16 @@ using CFunctionCallbackWithStrings =
+@@ -40,16 +40,16 @@ using CFunctionCallbackWithStrings =
               const v8::FastOneByteString& base);
  using CFunctionCallbackWithTwoUint8Arrays =
      int32_t (*)(v8::Local<v8::Value>,
@@ -219,7 +219,7 @@ index 38a4ff7e6c2c9997f004c7c1f94cb5a9ffc2ffe0..48e73168f994d79ae3564b813acb5546
                  uint32_t,
                  int64_t,
                  bool);
-@@ -58,18 +58,20 @@ using CFunctionWithBool = void (*)(v8::Local<v8::Value>, bool);
+@@ -68,18 +68,20 @@ using CFunctionWithBool = void (*)(v8::Local<v8::Value>,
  
  using CFunctionWriteString =
      uint32_t (*)(v8::Local<v8::Value> receiver,
@@ -246,19 +246,18 @@ index 38a4ff7e6c2c9997f004c7c1f94cb5a9ffc2ffe0..48e73168f994d79ae3564b813acb5546
  // This class manages the external references from the V8 heap
  // to the C++ addresses in Node.js.
 diff --git a/src/util.h b/src/util.h
-index a6da8720c499df54ab4608eb03cff905759c2232..43ef977363e565a6f9422c9454e25b8fe0b327d5 100644
+index b1f316eebc7199a3737f05a5f9a1dd7fc289490c..23a0a486244ce38277ef11df5806da1266b901ac 100644
 --- a/src/util.h
 +++ b/src/util.h
-@@ -57,6 +57,8 @@
- 
+@@ -59,6 +59,7 @@
  namespace node {
  
-+static constexpr size_t kMaxSizeInHeap = 64;                                 \
-+
+ constexpr char kPathSeparator = std::filesystem::path::preferred_separator;
++static constexpr size_t kMaxSizeInHeap = 64;
+ 
  #ifdef _WIN32
  /* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */
- #define PATH_MAX_BYTES (MAX_PATH * 4)
-@@ -573,6 +575,16 @@ class BufferValue : public MaybeStackBuffer<char> {
+@@ -576,6 +577,16 @@ class BufferValue : public MaybeStackBuffer<char> {
        static_cast<char*>(name->Buffer()->Data()) + name##_offset;              \
    if (name##_length > 0) CHECK_NE(name##_data, nullptr);
  

+ 2 - 2
patches/node/fix_remove_harmony-import-assertions_from_node_cc.patch

@@ -11,10 +11,10 @@ This patch can be removed when we upgrade to a V8 version that
 contains the above CL.
 
 diff --git a/src/node.cc b/src/node.cc
-index ccc1085a84b214d241687fa9ebd45b55b2cc60d8..1df8e1f00a0e2ffa63bfd4369240b837ab6a9c50 100644
+index f4365c0eda7330bd02a921608951902f41004f77..b2b10ffb572f010992f221de752618fd56b5d50e 100644
 --- a/src/node.cc
 +++ b/src/node.cc
-@@ -804,7 +804,7 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
+@@ -808,7 +808,7 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
    }
    // TODO(nicolo-ribaudo): remove this once V8 doesn't enable it by default
    // anymore.

+ 41 - 294
patches/node/fix_revert_src_lb_reducing_c_calls_of_esm_legacy_main_resolve.patch

@@ -15,10 +15,10 @@ to recognize asar files.
 This reverts commit 9cf2e1f55b8446a7cde23699d00a3be73aa0c8f1.
 
 diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
-index f3dad958b2ec275992554477b9344214c8c1e2c8..a086217046fd5ed7cfb09cfd2ed62f3987eb1f31 100644
+index f2fbb576da23fc0a48b0c979a263aa2dbe3600eb..97d3b4e9bd9303e1271bb62b1c9851da1100e019 100644
 --- a/lib/internal/modules/esm/resolve.js
 +++ b/lib/internal/modules/esm/resolve.js
-@@ -27,14 +27,13 @@ const { BuiltinModule } = require('internal/bootstrap/realm');
+@@ -28,14 +28,13 @@ const { BuiltinModule } = require('internal/bootstrap/realm');
  const fs = require('fs');
  const { getOptionValue } = require('internal/options');
  // Do not eagerly grab .manifest, it may be in TDZ
@@ -35,56 +35,36 @@ index f3dad958b2ec275992554477b9344214c8c1e2c8..a086217046fd5ed7cfb09cfd2ed62f39
  const {
    ERR_INPUT_TYPE_NOT_ALLOWED,
    ERR_INVALID_ARG_TYPE,
-@@ -154,34 +153,13 @@ function emitLegacyIndexDeprecation(url, packageJSONUrl, base, main) {
+@@ -183,6 +182,15 @@ const legacyMainResolveExtensionsIndexes = {
+   kResolvedByPackageAndNode: 9,
+ };
  
- const realpathCache = new SafeMap();
- 
--const legacyMainResolveExtensions = [
--  '',
--  '.js',
--  '.json',
--  '.node',
--  '/index.js',
--  '/index.json',
--  '/index.node',
--  './index.js',
--  './index.json',
--  './index.node',
--];
--
--const legacyMainResolveExtensionsIndexes = {
--  // 0-6: when packageConfig.main is defined
--  kResolvedByMain: 0,
--  kResolvedByMainJs: 1,
--  kResolvedByMainJson: 2,
--  kResolvedByMainNode: 3,
--  kResolvedByMainIndexJs: 4,
--  kResolvedByMainIndexJson: 5,
--  kResolvedByMainIndexNode: 6,
--  // 7-9: when packageConfig.main is NOT defined,
--  //      or when the previous case didn't found the file
--  kResolvedByPackageAndJs: 7,
--  kResolvedByPackageAndJson: 8,
--  kResolvedByPackageAndNode: 9,
--};
 +/**
 + * @param {string | URL} url
 + * @returns {boolean}
 + */
 +function fileExists(url) {
-+  return internalFsBinding.internalModuleStat(toNamespacedPath(toPathIfFileURL(url))) === 0;
++  const namespaced = toNamespacedPath(toPathIfFileURL(url));
++  return internalFsBinding.internalModuleStat(internalFsBinding, namespaced) === 0;
 +}
- 
++
  /**
   * Legacy CommonJS main resolution:
-@@ -196,22 +174,44 @@ const legacyMainResolveExtensionsIndexes = {
-  * @returns {URL}
-  */
- function legacyMainResolve(packageJSONUrl, packageConfig, base) {
--  const packageJsonUrlString = packageJSONUrl.href;
+  * 1. let M = pkg_url + (json main field)
+@@ -199,18 +207,45 @@ function legacyMainResolve(packageJSONUrl, packageConfig, base) {
+   assert(isURL(packageJSONUrl));
+   const pkgPath = fileURLToPath(new URL('.', packageJSONUrl));
+ 
+-  const baseStringified = isURL(base) ? base.href : base;
+-
+-  const resolvedOption = FSLegacyMainResolve(pkgPath, packageConfig.main, baseStringified);
 -
--  if (typeof packageJsonUrlString !== 'string') {
--    throw new ERR_INVALID_ARG_TYPE('packageJSONUrl', ['URL'], packageJSONUrl);
+-  const maybeMain = resolvedOption <= legacyMainResolveExtensionsIndexes.kResolvedByMainIndexNode ?
+-    packageConfig.main || './' : '';
+-  const resolvedPath = resolve(pkgPath, maybeMain + legacyMainResolveExtensions[resolvedOption]);
+-  const resolvedUrl = pathToFileURL(resolvedPath);
+-
+-  emitLegacyIndexDeprecation(resolvedUrl, resolvedPath, pkgPath, base, packageConfig.main);
 +  let guess;
 +  if (packageConfig.main !== undefined) {
 +    // Note: fs check redundances will be handled by Descriptor cache here.
@@ -105,277 +85,39 @@ index f3dad958b2ec275992554477b9344214c8c1e2c8..a086217046fd5ed7cfb09cfd2ed62f39
 +                                        packageJSONUrl)));
 +    else guess = undefined;
 +    if (guess) {
-+      emitLegacyIndexDeprecation(guess, packageJSONUrl, base,
-+                                 packageConfig.main);
++      emitLegacyIndexDeprecation(guess, fileURLToPath(guess), pkgPath,
++                                 base, packageConfig.main);
 +      return guess;
 +    }
-+    // Fallthrough.
-   }
--
--  const baseStringified = isURL(base) ? base.href : base;
--
--  const resolvedOption = FSLegacyMainResolve(packageJsonUrlString, packageConfig.main, baseStringified);
--
--  const baseUrl = resolvedOption <= legacyMainResolveExtensionsIndexes.kResolvedByMainIndexNode ? `./${packageConfig.main}` : '';
--  const resolvedUrl = new URL(baseUrl + legacyMainResolveExtensions[resolvedOption], packageJSONUrl);
--
--  emitLegacyIndexDeprecation(resolvedUrl, packageJSONUrl, base, packageConfig.main);
--
++  }
+ 
 -  return resolvedUrl;
++  // Fallthrough.
 +  if (fileExists(guess = new URL('./index.js', packageJSONUrl)));
 +  // So fs.
 +  else if (fileExists(guess = new URL('./index.json', packageJSONUrl)));
 +  else if (fileExists(guess = new URL('./index.node', packageJSONUrl)));
 +  else guess = undefined;
 +  if (guess) {
-+    emitLegacyIndexDeprecation(guess, packageJSONUrl, base, packageConfig.main);
++    emitLegacyIndexDeprecation(guess, fileURLToPath(guess), pkgPath,
++                                base, packageConfig.main);
 +    return guess;
 +  }
 +  // Not found.
-+  throw new ERR_MODULE_NOT_FOUND(
-+    fileURLToPath(new URL('.', packageJSONUrl)), fileURLToPath(base));
++  throw new ERR_MODULE_NOT_FOUND(pkgPath, fileURLToPath(base), null);
  }
  
  const encodedSepRegEx = /%2F|%5C/i;
-diff --git a/src/node_file.cc b/src/node_file.cc
-index 0bb70eb0fcd42ddf4d5e585065cf1ad8e74faab3..b565beae625d970ba92ab667a145d8897d4e8a6e 100644
---- a/src/node_file.cc
-+++ b/src/node_file.cc
-@@ -19,14 +19,12 @@
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- #include "node_file.h"  // NOLINT(build/include_inline)
--#include "ada.h"
- #include "aliased_buffer-inl.h"
- #include "memory_tracker-inl.h"
- #include "node_buffer.h"
- #include "node_errors.h"
- #include "node_external_reference.h"
- #include "node_file-inl.h"
--#include "node_metadata.h"
- #include "node_process-inl.h"
- #include "node_stat_watcher.h"
- #include "node_url.h"
-@@ -3208,146 +3206,6 @@ constexpr std::array<std::string_view, 10> legacy_main_extensions = {
- 
- }  // namespace
- 
--void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
--  CHECK_GE(args.Length(), 1);
--  CHECK(args[0]->IsString());
--
--  Environment* env = Environment::GetCurrent(args);
--  auto isolate = env->isolate();
--
--  Utf8Value utf8_package_json_url(isolate, args[0]);
--  auto package_json_url =
--      ada::parse<ada::url_aggregator>(utf8_package_json_url.ToStringView());
--
--  if (!package_json_url) {
--    THROW_ERR_INVALID_URL(isolate, "Invalid URL");
--    return;
--  }
--
--  std::string package_initial_file = "";
--
--  ada::result<ada::url_aggregator> file_path_url;
--  std::optional<std::string> initial_file_path;
--  std::string file_path;
--
--  if (args.Length() >= 2 && args[1]->IsString()) {
--    auto package_config_main = Utf8Value(isolate, args[1]).ToString();
--
--    file_path_url = ada::parse<ada::url_aggregator>(
--        std::string("./") + package_config_main, &package_json_url.value());
--
--    if (!file_path_url) {
--      THROW_ERR_INVALID_URL(isolate, "Invalid URL");
--      return;
--    }
--
--    initial_file_path = node::url::FileURLToPath(env, *file_path_url);
--    if (!initial_file_path.has_value()) {
--      return;
--    }
--
--    FromNamespacedPath(&initial_file_path.value());
--
--    package_initial_file = *initial_file_path;
--
--    for (int i = 0; i < legacy_main_extensions_with_main_end; i++) {
--      file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
--      // TODO(anonrig): Remove this when ToNamespacedPath supports std::string
--      Local<Value> local_file_path =
--          Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
--              .ToLocalChecked();
--      BufferValue buff_file_path(isolate, local_file_path);
--      ToNamespacedPath(env, &buff_file_path);
--
--      switch (FilePathIsFile(env, buff_file_path.ToString())) {
--        case BindingData::FilePathIsFileReturnType::kIsFile:
--          return args.GetReturnValue().Set(i);
--        case BindingData::FilePathIsFileReturnType::kIsNotFile:
--          continue;
--        case BindingData::FilePathIsFileReturnType::
--            kThrowInsufficientPermissions:
--          // the default behavior when do not have permission is to return
--          // and exit the execution of the method as soon as possible
--          // the internal function will throw the exception
--          return;
--        default:
--          UNREACHABLE();
--      }
--    }
--  }
--
--  file_path_url =
--      ada::parse<ada::url_aggregator>("./index", &package_json_url.value());
--
--  if (!file_path_url) {
--    THROW_ERR_INVALID_URL(isolate, "Invalid URL");
--    return;
--  }
--
--  initial_file_path = node::url::FileURLToPath(env, *file_path_url);
--  if (!initial_file_path.has_value()) {
--    return;
--  }
--
--  FromNamespacedPath(&initial_file_path.value());
--
--  for (int i = legacy_main_extensions_with_main_end;
--       i < legacy_main_extensions_package_fallback_end;
--       i++) {
--    file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
--    // TODO(anonrig): Remove this when ToNamespacedPath supports std::string
--    Local<Value> local_file_path =
--        Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
--            .ToLocalChecked();
--    BufferValue buff_file_path(isolate, local_file_path);
--    ToNamespacedPath(env, &buff_file_path);
--
--    switch (FilePathIsFile(env, buff_file_path.ToString())) {
--      case BindingData::FilePathIsFileReturnType::kIsFile:
--        return args.GetReturnValue().Set(i);
--      case BindingData::FilePathIsFileReturnType::kIsNotFile:
--        continue;
--      case BindingData::FilePathIsFileReturnType::kThrowInsufficientPermissions:
--        // the default behavior when do not have permission is to return
--        // and exit the execution of the method as soon as possible
--        // the internal function will throw the exception
--        return;
--      default:
--        UNREACHABLE();
--    }
--  }
--
--  if (package_initial_file == "")
--    package_initial_file = *initial_file_path + ".js";
--
--  std::optional<std::string> module_base;
--
--  if (args.Length() >= 3 && args[2]->IsString()) {
--    Utf8Value utf8_base_path(isolate, args[2]);
--    auto base_url =
--        ada::parse<ada::url_aggregator>(utf8_base_path.ToStringView());
--
--    if (!base_url) {
--      THROW_ERR_INVALID_URL(isolate, "Invalid URL");
--      return;
--    }
--
--    module_base = node::url::FileURLToPath(env, *base_url);
--    if (!module_base.has_value()) {
--      return;
--    }
--  } else {
--    THROW_ERR_INVALID_ARG_TYPE(
--        isolate,
--        "The \"base\" argument must be of type string or an instance of URL.");
--    return;
--  }
--
--  THROW_ERR_MODULE_NOT_FOUND(isolate,
--                             "Cannot find package '%s' imported from %s",
--                             package_initial_file,
--                             *module_base);
--}
- 
- void BindingData::MemoryInfo(MemoryTracker* tracker) const {
-   tracker->TrackField("stats_field_array", stats_field_array);
-@@ -3448,19 +3306,6 @@ InternalFieldInfoBase* BindingData::Serialize(int index) {
-   return info;
- }
- 
--void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
--                                             Local<ObjectTemplate> target) {
--  Isolate* isolate = isolate_data->isolate();
--
--  SetMethod(
--      isolate, target, "legacyMainResolve", BindingData::LegacyMainResolve);
--}
--
--void BindingData::RegisterExternalReferences(
--    ExternalReferenceRegistry* registry) {
--  registry->Register(BindingData::LegacyMainResolve);
--}
--
- static void CreatePerIsolateProperties(IsolateData* isolate_data,
-                                        Local<ObjectTemplate> target) {
-   Isolate* isolate = isolate_data->isolate();
-@@ -3520,7 +3365,6 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
-   SetMethod(isolate, target, "cpSyncCheckPaths", CpSyncCheckPaths);
- 
-   StatWatcher::CreatePerIsolateProperties(isolate_data, target);
--  BindingData::CreatePerIsolateProperties(isolate_data, target);
- 
-   target->Set(
-       FIXED_ONE_BYTE_STRING(isolate, "kFsStatsFieldsNumber"),
-@@ -3593,7 +3437,6 @@ BindingData* FSReqBase::binding_data() {
- void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
-   registry->Register(Access);
-   StatWatcher::RegisterExternalReferences(registry);
--  BindingData::RegisterExternalReferences(registry);
- 
-   registry->Register(GetFormatOfExtensionlessFile);
-   registry->Register(Close);
-diff --git a/src/node_file.h b/src/node_file.h
-index bdad1ae25f4892cbbfd8cc30c4d8b4a6f600edbc..5a3c462853aa784d9ef61ff4f63010848c48b92c 100644
---- a/src/node_file.h
-+++ b/src/node_file.h
-@@ -86,13 +86,6 @@ class BindingData : public SnapshotableObject {
-   SERIALIZABLE_OBJECT_METHODS()
-   SET_BINDING_ID(fs_binding_data)
- 
--  static void LegacyMainResolve(
--      const v8::FunctionCallbackInfo<v8::Value>& args);
--
--  static void CreatePerIsolateProperties(IsolateData* isolate_data,
--                                         v8::Local<v8::ObjectTemplate> ctor);
--  static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
--
-   void MemoryInfo(MemoryTracker* tracker) const override;
-   SET_SELF_SIZE(BindingData)
-   SET_MEMORY_INFO_NAME(BindingData)
 diff --git a/test/es-module/test-cjs-legacyMainResolve.js b/test/es-module/test-cjs-legacyMainResolve.js
-index 0bfeb567a22b1f9d9116b749d6cb3a8fda6bcc6a..17f137c595a9fef5f051fafc4682f206034c214c 100644
+index edb567bce403f2d4df482c2549c6f7cec78c3588..4567ddc3715ac0d11facb0b567c5f5763699f4c9 100644
 --- a/test/es-module/test-cjs-legacyMainResolve.js
 +++ b/test/es-module/test-cjs-legacyMainResolve.js
-@@ -82,7 +82,7 @@ describe('legacyMainResolve', () => {
-           {},
-           ''
-         ),
--      { message: /instance of URL/, code: 'ERR_INVALID_ARG_TYPE' },
-+      { message: 'Invalid URL', code: 'ERR_INVALID_URL' },
-     );
-   });
- 
 @@ -129,7 +129,7 @@ describe('legacyMainResolve', () => {
      );
      assert.throws(
        () => legacyMainResolve(packageJsonUrl, { main: null }, packageJsonUrl),
 -      { message: /index\.js/, code: 'ERR_MODULE_NOT_FOUND' },
-+      { code: 'ERR_INTERNAL_ASSERTION' },
++      { code: 'ERR_MODULE_NOT_FOUND' },
      );
    });
  
@@ -384,7 +126,7 @@ index 0bfeb567a22b1f9d9116b749d6cb3a8fda6bcc6a..17f137c595a9fef5f051fafc4682f206
      assert.throws(
        () => legacyMainResolve(packageJsonUrl, { main: null }, packageJsonUrl),
 -      { message: /index\.js/, code: 'ERR_MODULE_NOT_FOUND' },
-+      { code: 'ERR_INTERNAL_ASSERTION' },
++      { code: 'ERR_MODULE_NOT_FOUND' },
      );
    });
  
@@ -393,11 +135,11 @@ index 0bfeb567a22b1f9d9116b749d6cb3a8fda6bcc6a..17f137c595a9fef5f051fafc4682f206
      assert.throws(
        () => legacyMainResolve(packageJsonUrl, { main: './index.node' }, packageJsonUrl),
 -      { message: /index\.node/, code: 'ERR_MODULE_NOT_FOUND' },
-+      { code: 'ERR_INTERNAL_ASSERTION' },
++      { code: 'ERR_MODULE_NOT_FOUND' },
      );
    });
  
-@@ -163,7 +163,7 @@ describe('legacyMainResolve', () => {
+@@ -163,11 +163,11 @@ describe('legacyMainResolve', () => {
      );
      assert.throws(
        () => legacyMainResolve(packageJsonUrl, { main: null }, undefined),
@@ -405,4 +147,9 @@ index 0bfeb567a22b1f9d9116b749d6cb3a8fda6bcc6a..17f137c595a9fef5f051fafc4682f206
 +      { message: 'The "path" argument must be of type string or an instance of URL. Received undefined', code: 'ERR_INVALID_ARG_TYPE' },
      );
    });
- });
+ 
+-  it('should interpret main as a path, not a URL', () => {
++  it.skip('should interpret main as a path, not a URL', () => {
+     const packageJsonUrl = fixtures.fileURL('/es-modules/legacy-main-resolver/package.json');
+     assert.deepStrictEqual(
+       legacyMainResolve(packageJsonUrl, { main: '../folder%25with percentage#/' }, packageJsonUrl),

+ 0 - 29
patches/node/fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch

@@ -1,29 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: deepak1556 <[email protected]>
-Date: Tue, 16 Nov 2021 20:05:57 +0900
-Subject: fix: suppress clang -Wdeprecated-declarations in libuv
-
-Should be upstreamed.
-
-diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c
-index a96cb915930a30a49ba55fd7d15ea48f0b471f89..3c15f348bd3a9a42afcf0e4d0182d2d6f3d05cb1 100644
---- a/deps/uv/src/win/util.c
-+++ b/deps/uv/src/win/util.c
-@@ -1537,10 +1537,17 @@ int uv_os_uname(uv_utsname_t* buffer) {
-     #ifdef _MSC_VER
-     #pragma warning(suppress : 4996)
-     #endif
-+    #ifdef __clang__
-+    #pragma clang diagnostic push
-+    #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-+    #endif
-     if (GetVersionExW(&os_info) == 0) {
-       r = uv_translate_sys_error(GetLastError());
-       goto error;
-     }
-+    #ifdef __clang__
-+    #pragma clang diagnostic pop
-+    #endif
-   }
- 
-   /* Populate the version field. */

+ 51 - 0
patches/node/linux_try_preadv64_pwritev64_before_preadv_pwritev_4683.patch

@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Ben Noordhuis <[email protected]>
+Date: Tue, 28 Jan 2025 09:27:58 +0100
+Subject: linux: try preadv64/pwritev64 before preadv/pwritev (#4683)
+
+Fixes: https://github.com/libuv/libuv/issues/4678
+Refs: https://github.com/libuv/libuv/issues/4532
+
+diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c
+index 239ecda16a7eb9b40453502cf0362ae66366cf72..1631d9340bc10c2ac4c3d53a63ed9bc10f3e1c7c 100644
+--- a/deps/uv/src/unix/fs.c
++++ b/deps/uv/src/unix/fs.c
+@@ -461,12 +461,7 @@ static ssize_t uv__pwritev_emul(int fd,
+ 
+ /* The function pointer cache is an uintptr_t because _Atomic void*
+  * doesn't work on macos/ios/etc...
+- * Disable optimization on armv7 to work around the bug described in
+- * https://github.com/libuv/libuv/issues/4532
+  */
+-#if defined(__arm__) && (__ARM_ARCH == 7)
+-__attribute__((optimize("O0")))
+-#endif
+ static ssize_t uv__preadv_or_pwritev(int fd,
+                                      const struct iovec* bufs,
+                                      size_t nbufs,
+@@ -479,7 +474,12 @@ static ssize_t uv__preadv_or_pwritev(int fd,
+   p = (void*) atomic_load_explicit(cache, memory_order_relaxed);
+   if (p == NULL) {
+ #ifdef RTLD_DEFAULT
+-    p = dlsym(RTLD_DEFAULT, is_pread ? "preadv" : "pwritev");
++    /* Try _LARGEFILE_SOURCE version of preadv/pwritev first,
++     * then fall back to the plain version, for libcs like musl.
++     */
++    p = dlsym(RTLD_DEFAULT, is_pread ? "preadv64" : "pwritev64");
++    if (p == NULL)
++      p = dlsym(RTLD_DEFAULT, is_pread ? "preadv" : "pwritev");
+     dlerror();  /* Clear errors. */
+ #endif  /* RTLD_DEFAULT */
+     if (p == NULL)
+@@ -487,10 +487,7 @@ static ssize_t uv__preadv_or_pwritev(int fd,
+     atomic_store_explicit(cache, (uintptr_t) p, memory_order_relaxed);
+   }
+ 
+-  /* Use memcpy instead of `f = p` to work around a compiler bug,
+-   * see https://github.com/libuv/libuv/issues/4532
+-   */
+-  memcpy(&f, &p, sizeof(p));
++  f = p;
+   return f(fd, bufs, nbufs, off);
+ }
+ 

+ 10 - 10
patches/node/pass_all_globals_through_require.patch

@@ -6,7 +6,7 @@ Subject: Pass all globals through "require"
 (cherry picked from commit 7d015419cb7a0ecfe6728431a4ed2056cd411d62)
 
 diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
-index 451b7c2195e7ad3ab0bde95259e054dc431d7de9..d49941881e6cfd8647a6d44a57e0daaf1c874702 100644
+index 236b2484049c43ee9d6b9c728561b80813b12982..ccd038dc136480cdd84a13e58f4012b71cd40928 100644
 --- a/lib/internal/modules/cjs/loader.js
 +++ b/lib/internal/modules/cjs/loader.js
 @@ -182,6 +182,13 @@ const {
@@ -23,18 +23,18 @@ index 451b7c2195e7ad3ab0bde95259e054dc431d7de9..d49941881e6cfd8647a6d44a57e0daaf
  const {
    isProxy,
  } = require('internal/util/types');
-@@ -1541,10 +1548,12 @@ Module.prototype._compile = function(content, filename, format) {
-   this[kIsExecuting] = true;
-   if (inspectorWrapper) {
-     result = inspectorWrapper(compiledWrapper, thisValue, exports,
--                              require, module, filename, dirname);
-+                              require, module, filename, dirname,
-+                              process, localGlobal, localBuffer);
+@@ -1557,10 +1564,12 @@ Module.prototype._compile = function(content, filename, format) {
+   if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) {
+     const { callAndPauseOnStart } = internalBinding('inspector');
+     result = callAndPauseOnStart(compiledWrapper, thisValue, exports,
+-                                 require, module, filename, dirname);
++                                 require, module, filename, dirname,
++                                 process, localGlobal, localBuffer);
    } else {
      result = ReflectApply(compiledWrapper, thisValue,
 -                          [exports, require, module, filename, dirname]);
-+                          [exports, require, module, filename,
-+                           dirname, process, localGlobal, localBuffer]);
++                          [exports, require, module, filename, dirname,
++                           process, localGlobal, localBuffer]);
    }
    this[kIsExecuting] = false;
    if (requireDepth === 0) { statCache = null; }

+ 1 - 1
patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch

@@ -7,7 +7,7 @@ We use this to allow node's 'fs' module to read from ASAR files as if they were
 a real filesystem.
 
 diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
-index f7a62364b6107ab0bad33ea2f745703c746991dc..bab2aaf3db66452216035db594dc3ebdc3606c8b 100644
+index 11d585bc5b3e47b36877ca8306b72f571acb7d09..65d42428c70a3242f7076f1c1a4cec027a9c9829 100644
 --- a/lib/internal/bootstrap/node.js
 +++ b/lib/internal/bootstrap/node.js
 @@ -134,6 +134,10 @@ process.domain = null;

+ 0 - 45
patches/node/src_provide_workaround_for_container-overflow.patch

@@ -1,45 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Daniel Lemire <[email protected]>
-Date: Tue, 29 Oct 2024 12:28:47 -0400
-Subject: src: provide workaround for container-overflow
-
-Address a sanitizer error 'container-overflow', which happens only on systems where the
-standard library has been annotated to warn about reads between the std::string's end
-and the end of the its allocated memory (std::string:capacity). This reads are memory safe
-but they can also be a sign that there is a real bug. In the instance of issue 55584,
-it is not a bug, it is a false positive.
-
-In some instances, it is possible to indicate to the compiler that we want to disallow
-these checks to avoid the false positive, but I could not find documentation on this topic
-In a future release of simdjson, we will provide a more convenient function that
-avoids such ugly workaround.
-
-diff --git a/src/node_modules.cc b/src/node_modules.cc
-index 3bedd2dfecb49c3f69ea59b70d72b8b6fc605132..2b0e4905dd557e73542cf052ba81327b1e1e471f 100644
---- a/src/node_modules.cc
-+++ b/src/node_modules.cc
-@@ -100,11 +100,23 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
-   if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
-     return nullptr;
-   }
-+  // In some systems, std::string is annotated to generate an
-+  // AddressSanitizer: container-overflow error when reading beyond the end of
-+  // the string even when we are still within the capacity of the string.
-+  // https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow
-+  // https://github.com/nodejs/node/issues/55584
-+  // The next lines are a workaround to avoid this false positive.
-+  size_t json_length = package_config.raw_json.size();
-+  package_config.raw_json.append(simdjson::SIMDJSON_PADDING, ' ');
-+  simdjson::padded_string_view json_view(package_config.raw_json.data(),
-+                                         json_length,
-+                                         package_config.raw_json.size());
-+  // End of workaround
- 
-   simdjson::ondemand::document document;
-   simdjson::ondemand::object main_object;
-   simdjson::error_code error =
--      binding_data->json_parser.iterate(package_config.raw_json).get(document);
-+      binding_data->json_parser.iterate(json_view).get(document);
- 
-   const auto throw_invalid_package_config = [error_context, path, realm]() {
-     if (error_context == nullptr) {

+ 9 - 9
patches/node/src_remove_dependency_on_wrapper-descriptor-based_cppheap.patch

@@ -16,7 +16,7 @@ patch:
 (cherry picked from commit 30329d06235a9f9733b1d4da479b403462d1b326)
 
 diff --git a/src/env-inl.h b/src/env-inl.h
-index 28a15aa741ddd40c664aae641797e7cc2813442f..08fe98e10b7716c694bbc882299fe0ed9e282d73 100644
+index c460018af954e6333cd937059ae5dc81f179d8ca..d266eca6fc3300e657383feb4bb7a7194da79275 100644
 --- a/src/env-inl.h
 +++ b/src/env-inl.h
 @@ -62,31 +62,6 @@ inline uv_loop_t* IsolateData::event_loop() const {
@@ -52,7 +52,7 @@ index 28a15aa741ddd40c664aae641797e7cc2813442f..08fe98e10b7716c694bbc882299fe0ed
    return &(wrapper_data_->cppgc_id);
  }
 diff --git a/src/env.cc b/src/env.cc
-index 665b064091d4cc42a4dc9ee5b0ea9e2f190338ca..4c8cb75945d82544ce2237d94cd1406d15efe424 100644
+index adb6cc1c2f1c0100b64e688d13e5ca81b1ae2775..579a15f0e1fdd97184ec81873dbc4547e747ec1d 100644
 --- a/src/env.cc
 +++ b/src/env.cc
 @@ -23,6 +23,7 @@
@@ -63,7 +63,7 @@ index 665b064091d4cc42a4dc9ee5b0ea9e2f190338ca..4c8cb75945d82544ce2237d94cd1406d
  
  #include <algorithm>
  #include <atomic>
-@@ -71,7 +72,6 @@ using v8::TryCatch;
+@@ -70,7 +71,6 @@ using v8::TryCatch;
  using v8::Uint32;
  using v8::Undefined;
  using v8::Value;
@@ -71,7 +71,7 @@ index 665b064091d4cc42a4dc9ee5b0ea9e2f190338ca..4c8cb75945d82544ce2237d94cd1406d
  using worker::Worker;
  
  int const ContextEmbedderTag::kNodeContextTag = 0x6e6f64;
-@@ -532,6 +532,14 @@ void IsolateData::CreateProperties() {
+@@ -531,6 +531,14 @@ void IsolateData::CreateProperties() {
    CreateEnvProxyTemplate(this);
  }
  
@@ -86,7 +86,7 @@ index 665b064091d4cc42a4dc9ee5b0ea9e2f190338ca..4c8cb75945d82544ce2237d94cd1406d
  constexpr uint16_t kDefaultCppGCEmbedderID = 0x90de;
  Mutex IsolateData::isolate_data_mutex_;
  std::unordered_map<uint16_t, std::unique_ptr<PerIsolateWrapperData>>
-@@ -569,36 +577,16 @@ IsolateData::IsolateData(Isolate* isolate,
+@@ -568,36 +576,16 @@ IsolateData::IsolateData(Isolate* isolate,
    v8::CppHeap* cpp_heap = isolate->GetCppHeap();
  
    uint16_t cppgc_id = kDefaultCppGCEmbedderID;
@@ -130,7 +130,7 @@ index 665b064091d4cc42a4dc9ee5b0ea9e2f190338ca..4c8cb75945d82544ce2237d94cd1406d
  
    {
      // GC could still be run after the IsolateData is destroyed, so we store
-@@ -630,11 +618,12 @@ IsolateData::~IsolateData() {
+@@ -629,11 +617,12 @@ IsolateData::~IsolateData() {
    }
  }
  
@@ -146,7 +146,7 @@ index 665b064091d4cc42a4dc9ee5b0ea9e2f190338ca..4c8cb75945d82544ce2237d94cd1406d
  
  void IsolateData::MemoryInfo(MemoryTracker* tracker) const {
 diff --git a/src/env.h b/src/env.h
-index 49ca9c0042ccf22ad1fffa54f05fd443cbc681ba..945535d0dc40f1a32f7e3ecf7d50361e591ba6c8 100644
+index 0a3f09ebc7e2e7c1f8b9499d4439e2ca90b86810..d6f412cb13460f97f9444af397c8025c7a8bd290 100644
 --- a/src/env.h
 +++ b/src/env.h
 @@ -175,10 +175,6 @@ class NODE_EXTERN_PRIVATE IsolateData : public MemoryRetainer {
@@ -161,10 +161,10 @@ index 49ca9c0042ccf22ad1fffa54f05fd443cbc681ba..945535d0dc40f1a32f7e3ecf7d50361e
    inline MultiIsolatePlatform* platform() const;
    inline const SnapshotData* snapshot_data() const;
 diff --git a/src/node.h b/src/node.h
-index 40880ccaca694f28ae47676254b1c0cc36de0d93..8e1114148bf5e961620726183f4979977dc14714 100644
+index 120e3a1042e29590cbbf4be258a1cd2d3d4f0043..afb26ec5690ccd65a3c36f8b8a1b2de416b9d843 100644
 --- a/src/node.h
 +++ b/src/node.h
-@@ -1558,24 +1558,14 @@ void RegisterSignalHandler(int signal,
+@@ -1552,24 +1552,14 @@ void RegisterSignalHandler(int signal,
                             bool reset_handler = false);
  #endif  // _WIN32
  

+ 17 - 26
patches/node/src_stop_using_deprecated_fields_of_fastapicallbackoptions.patch

@@ -26,10 +26,10 @@ index 3d8ccc77b5952a999c5fe48792259d32b402c460..867a1c4aca54b9d41490d23a5eb55088
    }
  
 diff --git a/src/histogram.cc b/src/histogram.cc
-index 4dbdea9be5721486d71a9dda77311b4919d450a3..4aacaa2a5d12533a039b4b96cb7f1fd79063d50f 100644
+index c62a5b8952400ff0dd8818c31a3e07622b63725c..36f61f57e951e1abfeb2fedb831b55c61363bcbc 100644
 --- a/src/histogram.cc
 +++ b/src/histogram.cc
-@@ -193,7 +193,8 @@ void HistogramBase::FastRecord(Local<Value> receiver,
+@@ -195,7 +195,8 @@ void HistogramBase::FastRecord(Local<Value> unused,
                                 const int64_t value,
                                 FastApiCallbackOptions& options) {
    if (value < 1) {
@@ -40,14 +40,13 @@ index 4dbdea9be5721486d71a9dda77311b4919d450a3..4aacaa2a5d12533a039b4b96cb7f1fd7
    }
    HistogramBase* histogram;
 diff --git a/src/node_file.cc b/src/node_file.cc
-index b565beae625d970ba92ab667a145d8897d4e8a6e..31c2fe82299d6905855c4efffeea4a4d161a88d5 100644
+index 4bdbfa1be2c22f6a823acc380efe15c8d72f66ce..83f482612fae2d7ebf9bfd6817d334c239f8a218 100644
 --- a/src/node_file.cc
 +++ b/src/node_file.cc
-@@ -1049,23 +1049,10 @@ static int32_t FastInternalModuleStat(
-     const FastOneByteString& input,
+@@ -1060,13 +1060,8 @@ static int32_t FastInternalModuleStat(
      // NOLINTNEXTLINE(runtime/references) This is V8 api.
      FastApiCallbackOptions& options) {
--  // This needs a HandleScope which needs an isolate.
+   // This needs a HandleScope which needs an isolate.
 -  Isolate* isolate = Isolate::TryGetCurrent();
 -  if (!isolate) {
 -    options.fallback = true;
@@ -55,29 +54,20 @@ index b565beae625d970ba92ab667a145d8897d4e8a6e..31c2fe82299d6905855c4efffeea4a4d
 -  }
 -
 -  HandleScope scope(isolate);
--  Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked());
 +  Environment* env = Environment::GetCurrent(options.isolate);
 +  HandleScope scope(env->isolate());
  
    auto path = std::filesystem::path(input.data, input.data + input.length);
--  if (UNLIKELY(!env->permission()->is_granted(
--          env, permission::PermissionScope::kFileSystemRead, path.string()))) {
--    options.fallback = true;
--    return -1;
--  }
--
-   switch (std::filesystem::status(path).type()) {
-     case std::filesystem::file_type::directory:
-       return 1;
+ 
 diff --git a/src/node_wasi.cc b/src/node_wasi.cc
-index ad1da44a01f437c97e06a3857eebd2edcebc83da..7123278e1a0942b61a76e9b1e7464eb8b5064079 100644
+index 468c2e59903fefe58d9c178d3afac3ef5b09f611..23a376e52e08a8af49dd47c47488552e01287426 100644
 --- a/src/node_wasi.cc
 +++ b/src/node_wasi.cc
-@@ -248,17 +248,18 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
-   WASI* wasi = reinterpret_cast<WASI*>(BaseObject::FromJSObject(receiver));
-   if (UNLIKELY(wasi == nullptr)) return EinvalError<R>();
+@@ -251,17 +251,19 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
+     return EinvalError<R>();
+   }
  
--  if (UNLIKELY(options.wasm_memory == nullptr || wasi->memory_.IsEmpty())) {
+-  if (options.wasm_memory == nullptr || wasi->memory_.IsEmpty()) [[unlikely]] {
 -    // fallback to slow path which to throw an error about missing memory.
 -    options.fallback = true;
 +  v8::Isolate* isolate = receiver->GetIsolate();
@@ -87,15 +77,16 @@ index ad1da44a01f437c97e06a3857eebd2edcebc83da..7123278e1a0942b61a76e9b1e7464eb8
      return EinvalError<R>();
    }
 -  uint8_t* memory = nullptr;
--  CHECK(LIKELY(options.wasm_memory->getStorageIfAligned(&memory)));
-+  Local<ArrayBuffer> ab = wasi->memory_.Get(isolate)->Buffer();
-+  size_t mem_size = ab->ByteLength();
-+  char* mem_data = static_cast<char*>(ab->Data());
-+  CHECK_NOT_NULL(mem_data);
+-  CHECK(options.wasm_memory->getStorageIfAligned(&memory));
  
 -  return F(*wasi,
 -           {reinterpret_cast<char*>(memory), options.wasm_memory->length()},
 -           args...);
++  Local<ArrayBuffer> ab = wasi->memory_.Get(isolate)->Buffer();
++  size_t mem_size = ab->ByteLength();
++  char* mem_data = static_cast<char*>(ab->Data());
++  CHECK_NOT_NULL(mem_data);
++
 +  return F(*wasi, {mem_data, mem_size}, args...);
  }
  

+ 30 - 15
patches/node/support_v8_sandboxed_pointers.patch

@@ -7,10 +7,10 @@ This refactors several allocators to allocate within the V8 memory cage,
 allowing them to be compatible with the V8_SANDBOXED_POINTERS feature.
 
 diff --git a/src/api/environment.cc b/src/api/environment.cc
-index 77c20a4b6b9db414444974f68c5def8788386d2b..a3c5697ef5b20a9dc43bfcd3513e703989f64d2d 100644
+index ad323fc800a33c010b0504a4aa55c107498dee26..fc9b056d2f7e25109100fbde5f3ab0aebc8c619a 100644
 --- a/src/api/environment.cc
 +++ b/src/api/environment.cc
-@@ -101,6 +101,14 @@ MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
+@@ -102,6 +102,14 @@ MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
    return result;
  }
  
@@ -26,7 +26,7 @@ index 77c20a4b6b9db414444974f68c5def8788386d2b..a3c5697ef5b20a9dc43bfcd3513e7039
    void* ret;
    if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers)
 diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc
-index 33ffbbb85d05f5356183e3aa1ca23707c5629b5d..008d212ebe25b0022020379aa08963c12828940c 100644
+index f973941b3b9ea954f35f2ea135f8ee3d77b98958..743c63ff7e3f526829919a8f2de7ebd625a93fbc 100644
 --- a/src/crypto/crypto_dh.cc
 +++ b/src/crypto/crypto_dh.cc
 @@ -51,6 +51,25 @@ void DiffieHellman::MemoryInfo(MemoryTracker* tracker) const {
@@ -64,7 +64,7 @@ index 33ffbbb85d05f5356183e3aa1ca23707c5629b5d..008d212ebe25b0022020379aa08963c1
    auto ab = ArrayBuffer::New(env->isolate(), std::move(backing));
    return Buffer::New(env, ab, 0, ab->ByteLength()).FromMaybe(Local<Value>());
 diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
-index ee81048caab4ccfe26ea9e677782c9c955d162a9..643c9d31dc2737faa2ec51684ffceb35a1014a58 100644
+index 8a6a36a3c31532ed585c287ba8cee14026d315b4..3d449b5853f359d63e1b88671a857bf9152ff6af 100644
 --- a/src/crypto/crypto_util.cc
 +++ b/src/crypto/crypto_util.cc
 @@ -326,10 +326,35 @@ ByteSource& ByteSource::operator=(ByteSource&& other) noexcept {
@@ -143,7 +143,7 @@ index ee81048caab4ccfe26ea9e677782c9c955d162a9..643c9d31dc2737faa2ec51684ffceb35
  void SecureHeapUsed(const FunctionCallbackInfo<Value>& args) {
  #ifndef OPENSSL_IS_BORINGSSL
 diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h
-index 922e77091d72172ed6cfc5e8477901e3608396c5..16a236c69caed6d60248c7973531a95adc8f2edb 100644
+index 5c717c6fdb0fc453fa6c0061077300926af31ed5..b5fbe8e964943ab6f3842b27638f20ff64a1c0c4 100644
 --- a/src/crypto/crypto_util.h
 +++ b/src/crypto/crypto_util.h
 @@ -268,7 +268,7 @@ class ByteSource {
@@ -156,10 +156,10 @@ index 922e77091d72172ed6cfc5e8477901e3608396c5..16a236c69caed6d60248c7973531a95a
    v8::Local<v8::ArrayBuffer> ToArrayBuffer(Environment* env);
  
 diff --git a/src/crypto/crypto_x509.cc b/src/crypto/crypto_x509.cc
-index af2f953f0388dbce326b0c519de3883552f8f009..7fb34057a486914dd886ec4d3d23be90cccb4fea 100644
+index 9b9bb7be9a8daca98a2635bf13cb6d1d561ea5fb..81afe2b5f7398f0c20b340648ca75022470be544 100644
 --- a/src/crypto/crypto_x509.cc
 +++ b/src/crypto/crypto_x509.cc
-@@ -174,6 +174,19 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, const BIOPointer& bio) {
+@@ -175,6 +175,19 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, const BIOPointer& bio) {
  MaybeLocal<Value> ToBuffer(Environment* env, BIOPointer* bio) {
    if (bio == nullptr || !*bio) return {};
    BUF_MEM* mem = *bio;
@@ -179,7 +179,7 @@ index af2f953f0388dbce326b0c519de3883552f8f009..7fb34057a486914dd886ec4d3d23be90
    auto backing = ArrayBuffer::NewBackingStore(
        mem->data,
        mem->length,
-@@ -181,6 +194,8 @@ MaybeLocal<Value> ToBuffer(Environment* env, BIOPointer* bio) {
+@@ -182,6 +195,8 @@ MaybeLocal<Value> ToBuffer(Environment* env, BIOPointer* bio) {
          BIOPointer free_me(static_cast<BIO*>(data));
        },
        bio->release());
@@ -189,10 +189,10 @@ index af2f953f0388dbce326b0c519de3883552f8f009..7fb34057a486914dd886ec4d3d23be90
    Local<Value> ret;
    if (!Buffer::New(env, ab, 0, ab->ByteLength()).ToLocal(&ret)) return {};
 diff --git a/src/node_i18n.cc b/src/node_i18n.cc
-index 43bb68351bf0a68285e464601013bbdbd5d5df5f..4126bbff080548c91154a6dcc437359c82a6c771 100644
+index 0bcf10a0b35accb8d6d5fe9891d4f52b27d40346..606c2021242e6967ea4195af3e2493a7d5745dae 100644
 --- a/src/node_i18n.cc
 +++ b/src/node_i18n.cc
-@@ -107,7 +107,7 @@ namespace {
+@@ -104,7 +104,7 @@ namespace {
  
  template <typename T>
  MaybeLocal<Object> ToBufferEndian(Environment* env, MaybeStackBuffer<T>* buf) {
@@ -201,7 +201,7 @@ index 43bb68351bf0a68285e464601013bbdbd5d5df5f..4126bbff080548c91154a6dcc437359c
    if (ret.IsEmpty())
      return ret;
  
-@@ -184,7 +184,7 @@ MaybeLocal<Object> TranscodeLatin1ToUcs2(Environment* env,
+@@ -181,7 +181,7 @@ MaybeLocal<Object> TranscodeLatin1ToUcs2(Environment* env,
      return {};
    }
  
@@ -210,7 +210,7 @@ index 43bb68351bf0a68285e464601013bbdbd5d5df5f..4126bbff080548c91154a6dcc437359c
  }
  
  MaybeLocal<Object> TranscodeFromUcs2(Environment* env,
-@@ -229,7 +229,7 @@ MaybeLocal<Object> TranscodeUcs2FromUtf8(Environment* env,
+@@ -226,7 +226,7 @@ MaybeLocal<Object> TranscodeUcs2FromUtf8(Environment* env,
      return {};
    }
  
@@ -219,7 +219,7 @@ index 43bb68351bf0a68285e464601013bbdbd5d5df5f..4126bbff080548c91154a6dcc437359c
  }
  
  MaybeLocal<Object> TranscodeUtf8FromUcs2(Environment* env,
-@@ -253,7 +253,7 @@ MaybeLocal<Object> TranscodeUtf8FromUcs2(Environment* env,
+@@ -250,7 +250,7 @@ MaybeLocal<Object> TranscodeUtf8FromUcs2(Environment* env,
      return {};
    }
  
@@ -229,10 +229,10 @@ index 43bb68351bf0a68285e464601013bbdbd5d5df5f..4126bbff080548c91154a6dcc437359c
  
  constexpr const char* EncodingName(const enum encoding encoding) {
 diff --git a/src/node_internals.h b/src/node_internals.h
-index fe2d25decd883085e4c3f368ab4acc01a7f66f6e..bcd5c87afcff9c56429443363c63fc8079521451 100644
+index 000ba16303740d7e48dcaf7b7c2e16fd750ac599..6396dc8f1a9db806ca4a4b547914680fcbaed9a1 100644
 --- a/src/node_internals.h
 +++ b/src/node_internals.h
-@@ -117,7 +117,9 @@ v8::Maybe<bool> InitializePrimordials(v8::Local<v8::Context> context);
+@@ -117,7 +117,9 @@ v8::Maybe<void> InitializePrimordials(v8::Local<v8::Context> context);
  
  class NodeArrayBufferAllocator : public ArrayBufferAllocator {
   public:
@@ -384,3 +384,18 @@ index 9787b14352753c5e0f8dc2b90093680e7cd10f1a..31af9e62396368af1b81f8841a705fd3
    auto ab = ArrayBuffer::New(isolate, std::move(bs));
    v8::Local<Uint8Array> u8 = v8::Uint8Array::New(ab, 0, 1);
  
+diff --git a/test/parallel/test-buffer-tostring-range.js b/test/parallel/test-buffer-tostring-range.js
+index 73fec107a36c3db4af6f492137d0ca174f2d0547..a1153ec381f7b12a1640b611073f6997e1ec5696 100644
+--- a/test/parallel/test-buffer-tostring-range.js
++++ b/test/parallel/test-buffer-tostring-range.js
+@@ -102,8 +102,8 @@ assert.throws(() => {
+ // Must not throw when start and end are within kMaxLength
+ // Cannot test on 32bit machine as we are testing the case
+ // when start and end are above the threshold
+-if (!common.openSSLIsBoringSSL) {
++/*
+ const threshold = 0xFFFFFFFF;
+ const largeBuffer = Buffer.alloc(threshold + 20);
+ largeBuffer.toString('utf8', threshold, threshold + 20);
+-}
++*/

+ 2 - 2
patches/node/test_formally_mark_some_tests_as_flaky.patch

@@ -7,7 +7,7 @@ Instead of disabling the tests, flag them as flaky so they still run
 but don't cause CI failures on flakes.
 
 diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status
-index 24e1a74886bad536dc08df75fbdb0508e4e1420a..7f3be73474557788050a9110b0e29e602b7d6397 100644
+index fd42444c7b216a4a1fa026efc1bbc1b5df8c7394..26f78764842aaaa781a9409dda2a7d3265351178 100644
 --- a/test/parallel/parallel.status
 +++ b/test/parallel/parallel.status
 @@ -5,6 +5,16 @@ prefix parallel
@@ -28,7 +28,7 @@ index 24e1a74886bad536dc08df75fbdb0508e4e1420a..7f3be73474557788050a9110b0e29e60
  test-net-write-fully-async-hex-string: PASS, FLAKY
  # https://github.com/nodejs/node/issues/52273
 diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status
-index a539649d5537376a6a2ac9a7a46051b8648f0cb1..a03c86b752772be7ae36fab31faeccf3b0ccff64 100644
+index 5f4445416d95fa588ccec309fd119cd40cfc8046..c0024ce74c619800ee812b1cac11297f82772356 100644
 --- a/test/sequential/sequential.status
 +++ b/test/sequential/sequential.status
 @@ -7,6 +7,18 @@ prefix sequential

+ 0 - 51
patches/node/test_make_test-node-output-v8-warning_generic.patch

@@ -1,51 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Shelley Vohr <[email protected]>
-Date: Tue, 16 Jan 2024 14:53:31 +0100
-Subject: test: make test-node-output-v8-warning generic
-
-Ref https://github.com/nodejs/node/pull/50421.
-
-The above CL migrated python snapshot testing to JS, and in the process
-added string replace calls to change 'node' as a hardcoded string to an
-asterisk. This was initially fixed in https://github.com/nodejs/node/pull/36489
-before being regressed in the above, as that PR essentially makes the wildcard
-meaningless. Fix it for now by replacing the process.argv0 basename instead.
-
-Some form of fix for this should be upstreamed.
-
-diff --git a/test/parallel/test-node-output-v8-warning.mjs b/test/parallel/test-node-output-v8-warning.mjs
-index 309e904c49b7124b64831293e0473a5d35249081..6636144f5074811f95bbe53a62718c8084088bdc 100644
---- a/test/parallel/test-node-output-v8-warning.mjs
-+++ b/test/parallel/test-node-output-v8-warning.mjs
-@@ -2,11 +2,18 @@ import '../common/index.mjs';
- import * as fixtures from '../common/fixtures.mjs';
- import * as snapshot from '../common/assertSnapshot.js';
- import { describe, it } from 'node:test';
-+import { basename } from 'node:path';
- 
- function replaceNodeVersion(str) {
-   return str.replaceAll(process.version, '*');
- }
- 
-+function replaceExecName(str) {
-+  // Copied from lib/internal/process/warning.js
-+  const baseName = basename(process.argv0 || 'node', '.exe');
-+  return str.replaceAll(`${baseName} --`, '* --');
-+}
-+
- describe('v8 output', { concurrency: !process.env.TEST_PARALLEL }, () => {
-   function normalize(str) {
-     return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
-@@ -15,10 +22,10 @@ describe('v8 output', { concurrency: !process.env.TEST_PARALLEL }, () => {
-     .replaceAll('*test*', '*')
-     .replaceAll(/.*?\*fixtures\*v8\*/g, '(node:*) V8: *') // Replace entire path before fixtures/v8
-     .replaceAll('*fixtures*v8*', '*')
--    .replaceAll('node --', '* --');
-   }
-+
-   const common = snapshot
--    .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion);
-+    .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, replaceExecName);
-   const defaultTransform = snapshot.transform(common, normalize);
-   const tests = [
-     { name: 'v8/v8_warning.js' },

+ 0 - 70
patches/node/win_almost_fix_race_detecting_esrch_in_uv_kill.patch

@@ -1,70 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Santiago Gimeno <[email protected]>
-Date: Tue, 5 Mar 2024 14:54:59 +0100
-Subject: win: almost fix race detecting ESRCH in uv_kill
-
-It might happen that only using `WaitForSingleObject()` with timeout 0
-could return WAIT_TIMEOUT as the process might not have been signaled
-yet. To improve things, first use `GetExitCodeProcess()` and check
-that `status` is not `STILL_ACTIVE`. Then, to cover for the case that the exit
-code was actually `STILL_ACTIVE` use `WaitForSingleObject()`. This could
-still be prone to the race condition but only for that case.
-
-diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c
-index 4e94dee90e13eede63d8e97ddc9992726f874ea9..f46f34289e8e7d3a2af914d89e6164b751a3e47d 100644
---- a/deps/uv/src/win/process.c
-+++ b/deps/uv/src/win/process.c
-@@ -1308,16 +1308,34 @@ static int uv__kill(HANDLE process_handle, int signum) {
-       /* Unconditionally terminate the process. On Windows, killed processes
-        * normally return 1. */
-       int err;
-+      DWORD status;
- 
-       if (TerminateProcess(process_handle, 1))
-         return 0;
- 
--      /* If the process already exited before TerminateProcess was called,.
-+      /* If the process already exited before TerminateProcess was called,
-        * TerminateProcess will fail with ERROR_ACCESS_DENIED. */
-       err = GetLastError();
--      if (err == ERROR_ACCESS_DENIED &&
--          WaitForSingleObject(process_handle, 0) == WAIT_OBJECT_0) {
--        return UV_ESRCH;
-+      if (err == ERROR_ACCESS_DENIED) {
-+        /* First check using GetExitCodeProcess() with status different from
-+         * STILL_ACTIVE (259). This check can be set incorrectly by the process,
-+         * though that is uncommon. */
-+        if (GetExitCodeProcess(process_handle, &status) &&
-+            status != STILL_ACTIVE) {
-+          return UV_ESRCH;
-+        }
-+
-+        /* But the process could have exited with code == STILL_ACTIVE, use then
-+         * WaitForSingleObject with timeout zero. This is prone to a race
-+         * condition as it could return WAIT_TIMEOUT because the handle might
-+         * not have been signaled yet.That would result in returning the wrong
-+         * error code here (UV_EACCES instead of UV_ESRCH), but we cannot fix
-+         * the kernel synchronization issue that TerminateProcess is
-+         * inconsistent with WaitForSingleObject with just the APIs available to
-+         * us in user space. */
-+        if (WaitForSingleObject(process_handle, 0) == WAIT_OBJECT_0) {
-+          return UV_ESRCH;
-+        }
-       }
- 
-       return uv_translate_sys_error(err);
-@@ -1325,6 +1343,14 @@ static int uv__kill(HANDLE process_handle, int signum) {
- 
-     case 0: {
-       /* Health check: is the process still alive? */
-+      DWORD status;
-+
-+      if (!GetExitCodeProcess(process_handle, &status))
-+        return uv_translate_sys_error(GetLastError());
-+
-+      if (status != STILL_ACTIVE)
-+        return UV_ESRCH;
-+
-       switch (WaitForSingleObject(process_handle, 0)) {
-         case WAIT_OBJECT_0:
-           return UV_ESRCH;

+ 4 - 0
script/node-disabled-tests.json

@@ -1,6 +1,7 @@
 [
   "abort/test-abort-backtrace",
   "es-module/test-vm-compile-function-lineoffset",
+  "es-module/test-cjs-legacyMainResolve-permission.js",
   "parallel/test-async-context-frame",
   "parallel/test-bootstrap-modules",
   "parallel/test-child-process-fork-exec-path",
@@ -26,6 +27,7 @@
   "parallel/test-crypto-secure-heap",
   "parallel/test-dgram-send-cb-quelches-error",
   "parallel/test-domain-error-types",
+  "parallel/test-fs-readdir-types-symlinks",
   "parallel/test-fs-utimes-y2K38",
   "parallel/test-http2-clean-output",
   "parallel/test-http2-https-fallback",
@@ -64,6 +66,8 @@
   "parallel/test-snapshot-namespaced-builtin",
   "parallel/test-snapshot-net",
   "parallel/test-snapshot-reproducible",
+  "parallel/test-snapshot-stack-trace-limit",
+  "parallel/test-snapshot-stack-trace-limit-mutation",
   "parallel/test-snapshot-typescript",
   "parallel/test-snapshot-umd",
   "parallel/test-snapshot-warning",