Files
electron/patches/node/fix_assert_module_in_the_renderer_process.patch
electron-roller[bot] f6d054f0fb chore: bump node to v22.17.0 (38-x-y) (#47556)
* chore: bump node in DEPS to v22.17.0

* build: use //third_party/simdutf by default in GN

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

* chore: adjust crypto specs:

- https://github.com/nodejs/node/pull/58117
- https://github.com/nodejs/node/pull/58387

* deps: update libuv to 1.51.0

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

* test: fix test-buffer-tostring-range on allocation failure

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

* build: use FILE_OFFSET_BITS=64 esp. on 32-bit arch

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

* build: use //third_party/simdutf by default in GN

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

* inspector: add protocol method Network.dataReceived

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

* test: force slow JSON.stringify path for overflow

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

* chore: fixup patch indices

* 6049967: Remove protocol::Maybe and roll inspector_protocol

https://chromium-review.googlesource.com/c/chromium/src/+/6049967

* chore: fixup crypto test patch

* src: fix module buffer allocation

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

* crypto: expose process.features.openssl_is_boringssl

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

* util: add internal assignFunctionName() function

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

* build: fix pointer compression builds

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

* chore: put back config options

* fixup! deps: update libuv to 1.51.0

* chore: update patches

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 14:49:12 +02:00

68 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 16 Aug 2023 19:15:29 +0200
Subject: fix: assert module in the renderer process
When creating a Node.js Environment, embedders have the option to disable Node.js'
default overriding of Error.prepareStackTrace. However, the assert module depends on
a WeakMap that is populated with the error stacktraces in the overridden function.
This adds handling to fall back to the default implementation if Error.prepareStackTrace
if the override has been disabled.
This will be upstreamed.
diff --git a/lib/internal/assert/utils.js b/lib/internal/assert/utils.js
index 59b5a16f1309a5e4055bccfdb7a529045ad30402..bfdaf6211466a01b64b7942f7b16c480283278ff 100644
--- a/lib/internal/assert/utils.js
+++ b/lib/internal/assert/utils.js
@@ -25,6 +25,7 @@ const AssertionError = require('internal/assert/assertion_error');
const { openSync, closeSync, readSync } = require('fs');
const { EOL } = require('internal/constants');
const { BuiltinModule } = require('internal/bootstrap/realm');
+const { getEmbedderOptions } = require('internal/options');
const { isError } = require('internal/util');
const errorCache = new SafeMap();
@@ -167,8 +168,16 @@ function getErrMessage(message, fn) {
ErrorCaptureStackTrace(err, fn);
if (errorStackTraceLimitIsWritable) Error.stackTraceLimit = tmpLimit;
- overrideStackTrace.set(err, (_, stack) => stack);
- const call = err.stack[0];
+ let call;
+ if (getEmbedderOptions().hasPrepareStackTraceCallback) {
+ overrideStackTrace.set(err, (_, stack) => stack);
+ call = err.stack[0];
+ } else {
+ const tmpPrepare = Error.prepareStackTrace;
+ Error.prepareStackTrace = (_, stack) => stack;
+ call = err.stack[0];
+ Error.prepareStackTrace = tmpPrepare;
+ }
let filename = call.getFileName();
const line = call.getLineNumber() - 1;
diff --git a/src/node_options.cc b/src/node_options.cc
index 14f7764c995e8de6582faf58c9b98a9cbe4fab73..d2e945b1d6ef6729709cc73c238cfae46d4e56b6 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -1560,14 +1560,16 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
}
Isolate* isolate = args.GetIsolate();
- constexpr size_t kOptionsSize = 4;
+ constexpr size_t kOptionsSize = 5;
std::array<Local<Name>, kOptionsSize> names = {
+ FIXED_ONE_BYTE_STRING(env->isolate(), "hasPrepareStackTraceCallback"),
FIXED_ONE_BYTE_STRING(env->isolate(), "shouldNotRegisterESMLoader"),
FIXED_ONE_BYTE_STRING(env->isolate(), "noGlobalSearchPaths"),
FIXED_ONE_BYTE_STRING(env->isolate(), "noBrowserGlobals"),
FIXED_ONE_BYTE_STRING(env->isolate(), "hasEmbedderPreload")};
std::array<Local<Value>, kOptionsSize> values = {
+ Boolean::New(isolate, env->prepare_stack_trace_callback().IsEmpty()),
Boolean::New(isolate, env->should_not_register_esm_loader()),
Boolean::New(isolate, env->no_global_search_paths()),
Boolean::New(isolate, env->no_browser_globals()),