Files
electron/patches/node/src_stop_using_deprecated_fields_of_fastapicallbackoptions.patch
electron-roller[bot] 3083fab4e4 chore: bump node to v22.21.1 (38-x-y) (#48615)
* chore: bump node in DEPS to v22.21.0

* chore: bump node in DEPS to v22.21.1

* chore: update patches

* lib,src: refactor assert to load error source from memory

nodejs/node#59751

* src: add percentage support to --max-old-space-size

nodejs/node#59082

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2025-10-30 17:05:42 +01:00

74 lines
2.9 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 dbc46400501b61814d5be0ec1cb01b0dcd94e1d0..fe669d40c31a29334b047b9cfee3067f64ef0a7b 100644
--- a/src/crypto/crypto_timing.cc
+++ b/src/crypto/crypto_timing.cc
@@ -60,7 +60,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 4a67b4a725ff768cbd10aef72a84af311d6ec9ec..ec7d5b1120724b7c752f92a3e3124a33cf51c0f5 100644
--- a/src/histogram.cc
+++ b/src/histogram.cc
@@ -187,7 +187,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_wasi.cc b/src/node_wasi.cc
index 85e549e4592e1d718eced31ae165dee250149b08..9b5ada71c174567498c4902259d97f9d11fefb91 100644
--- a/src/node_wasi.cc
+++ b/src/node_wasi.cc
@@ -274,17 +274,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 {