Files
electron/patches/node/src_stop_using_deprecated_fields_of_fastapicallbackoptions.patch
electron-roller[bot] cb445b3bbd chore: bump node to v22.15.0 (main) (#46742)
* chore: bump node in DEPS to v22.15.0

* inspector: fix GN build

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

* test: search cctest files

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

* crypto: fix missing OPENSSL_NO_ENGINE guard

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

* test,crypto: make tests work for BoringSSL

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

* module: use synchronous hooks for preparsing in import(cjs)

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

* deps: update simdjson to 3.12.0

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

* build: remove explicit linker call to libm on macOS

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

* test: make eval snapshot comparison more flexible

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

* src: allow embedder customization of OOMErrorHandler

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

* src: do not pass nullptr to std::string ctor

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

* src: lock the isolate properly in IsolateData destructor

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

* chore: shrink --trace-atomics-wait patch

* chore: fixup patch indices

* build: fix GN build failure

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

* crypto: expose security levels

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

* zlib: add zstd support

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

* test: move crypto related common utilities in common/crypto

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

* cli: move --trace-atomics-wait to eol

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

* test: disable test-https-client-renegotiation-limit

BoringSSL doesn't support caller-initiated renegotiation - see
https://source.chromium.org/chromium/chromium/src/+/main:third_party/boringssl/src/ssl/ssl_lib.cc;l=1627-1631

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-05-05 10:23:17 +02:00

94 lines
3.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andreas Haas <ahaas@chromium.org>
Date: Sun, 28 Jul 2024 09:20:12 +0200
Subject: src: stop using deprecated fields of `v8::FastApiCallbackOptions`
Two fields on the `v8::FastApiCallbackOptions` struct were deprecated
recently: `fallback` and `wasm_memory`. This PR removes uses of these
two fields in node.js.
(This is a subset of upstream commit d0000b118 from the `canary-base`
branch of Node.js. This patch can be removed when Electron upgrades to
a stable Node release that contains the change. -- Charles)
diff --git a/src/crypto/crypto_timing.cc b/src/crypto/crypto_timing.cc
index 3d8ccc77b5952a999c5fe48792259d32b402c460..867a1c4aca54b9d41490d23a5eb55088b7e941cc 100644
--- a/src/crypto/crypto_timing.cc
+++ b/src/crypto/crypto_timing.cc
@@ -59,7 +59,8 @@ bool FastTimingSafeEqual(Local<Value> receiver,
if (a.length() != b.length() || !a.getStorageIfAligned(&data_a) ||
!b.getStorageIfAligned(&data_b)) {
TRACK_V8_FAST_API_CALL("crypto.timingSafeEqual.error");
- options.fallback = true;
+ v8::HandleScope scope(options.isolate);
+ THROW_ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH(options.isolate);
return false;
}
diff --git a/src/histogram.cc b/src/histogram.cc
index 0f0cde7be431dcb80c5314b1a9da49886c436d1c..f6d2bd439cad8b9f91c9d9a6cdb302e64130a5e2 100644
--- a/src/histogram.cc
+++ b/src/histogram.cc
@@ -195,7 +195,8 @@ void HistogramBase::FastRecord(Local<Value> unused,
const int64_t value,
FastApiCallbackOptions& options) {
if (value < 1) {
- options.fallback = true;
+ Environment* env = Environment::GetCurrent(options.isolate);
+ THROW_ERR_OUT_OF_RANGE(env, "value is out of range");
return;
}
HistogramBase* histogram;
diff --git a/src/node_file.cc b/src/node_file.cc
index c7915e2c8161a5d0fa05ccce368ce9c44345c05d..23347379328794467a497c86cbae0b428b7ba791 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -1071,13 +1071,8 @@ static int32_t FastInternalModuleStat(
// NOLINTNEXTLINE(runtime/references) This is V8 api.
FastApiCallbackOptions& options) {
// This needs a HandleScope which needs an isolate.
- Isolate* isolate = Isolate::TryGetCurrent();
- if (!isolate) {
- options.fallback = true;
- return -1;
- }
-
- HandleScope scope(isolate);
+ Environment* env = Environment::GetCurrent(options.isolate);
+ HandleScope scope(env->isolate());
auto path = std::filesystem::path(input.data, input.data + input.length);
diff --git a/src/node_wasi.cc b/src/node_wasi.cc
index 090866960beb8f1759c99e95536924b8b61fb723..3f91b651b83a20e70d5b368e012f5ee4b9d16092 100644
--- a/src/node_wasi.cc
+++ b/src/node_wasi.cc
@@ -275,17 +275,19 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
return EinvalError<R>();
}
- 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();
+ v8::HandleScope handle_scope(isolate);
+ if (wasi->memory_.IsEmpty()) {
+ THROW_ERR_WASI_NOT_STARTED(isolate);
return EinvalError<R>();
}
- uint8_t* memory = nullptr;
- 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...);
}
namespace {