* chore: upgrade to Node.js v20

* src: allow embedders to override NODE_MODULE_VERSION

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

* src: fix missing trailing ,

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

* src,tools: initialize cppgc

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

* tools: allow passing absolute path of config.gypi in js2c

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

* tools: port js2c.py to C++

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

* doc,lib: disambiguate the old term, NativeModule

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

* chore: fixup Node.js BSSL tests

* https://github.com/nodejs/node/pull/49492
* https://github.com/nodejs/node/pull/44498

* deps: upgrade to libuv 1.45.0

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

* deps: update V8 to 10.7

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

* test: use gcUntil() in test-v8-serialize-leak

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

* module: make CJS load from ESM loader

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

* src: make BuiltinLoader threadsafe and non-global

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

* chore: address changes to CJS/ESM loading

* module: make CJS load from ESM loader (https://github.com/nodejs/node/pull/47999)
* lib: improve esm resolve performance (https://github.com/nodejs/node/pull/46652)

* bootstrap: optimize modules loaded in the built-in snapshot

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

* test: mark test-runner-output as flaky

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

* lib: lazy-load deps in modules/run_main.js

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

* url: use private properties for brand check

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

* test: refactor `test-node-output-errors`

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

* assert: deprecate callTracker

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

* src: cast v8::Object::GetInternalField() return value to v8::Value

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

* test: adapt test-v8-stats for V8 update

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

* tls: ensure TLS Sockets are closed if the underlying wrap closes

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

* test: deflake test-tls-socket-close

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

* net: fix crash due to simultaneous close/shutdown on JS Stream Sockets

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

* net: use asserts in JS Socket Stream to catch races in future

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

* lib: fix BroadcastChannel initialization location

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

* src: create BaseObject with node::Realm

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

* src: implement DataQueue and non-memory resident Blob

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

* sea: add support for V8 bytecode-only caching

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

* chore: fixup patch indices

* gyp: put filenames in variables

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

* build: modify js2c.py into GN executable

* fix: (WIP) handle string replacement of fs -> original-fs

* [v20.x] backport vm-related memory fixes

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

* src: make BuiltinLoader threadsafe and non-global

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

* src: avoid copying string in fs_permission

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

* look upon my works ye mighty

and dispair

* chore: patch cleanup

* [api] Remove AllCan Read/Write

https://chromium-review.googlesource.com/c/v8/v8/+/5006387

* fix: missing include for NODE_EXTERN

* chore: fixup patch indices

* fix: fail properly when js2c fails in Node.js

* build: fix js2c root_gen_dir

* fix: lib/fs.js -> lib/original-fs.js

* build: fix original-fs file xforms

* fixup! module: make CJS load from ESM loader

* build: get rid of CppHeap for now

* build: add patch to prevent extra fs lookup on esm load

* build: greatly simplify js2c modifications

Moves our original-fs modifications back into a super simple python script action, wires up the output of that action into our call to js2c

* chore: update to handle moved internal/modules/helpers file

* test: update @types/node test

* feat: enable preventing cppgc heap creation

* feat: optionally prevent calling V8::EnableWebAssemblyTrapHandler

* fix: no cppgc initialization in the renderer

* gyp: put filenames in variables

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

* test: disable single executable tests

* fix: nan tests failing on node headers missing file

* tls,http2: send fatal alert on ALPN mismatch

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

* test: disable snapshot tests

* https://github.com/nodejs/node/pull/47887
* https://github.com/nodejs/node/pull/49684
* https://github.com/nodejs/node/pull/44193

* build: use deps/v8 for v8/tools

Node.js hard depends on these in their builtins

* test: fix edge snapshot stack traces

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

* build: remove js2c //base dep

* build: use electron_js2c_toolchain to build node_js2c

* fix: don't create SafeSet outside packageResolve

Fixes failure in parallel/test-require-delete-array-iterator:

=== release test-require-delete-array-iterator ===
Path: parallel/test-require-delete-array-iterator
node:internal/per_context/primordials:426
    constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
                     ^

TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
    at new Set (<anonymous>)
    at new SafeSet (node:internal/per_context/primordials:426:22)

* fix: failing crashReporter tests on Linux

These were failing because our change from node::InitializeNodeWithArgs to
node::InitializeOncePerProcess meant that we now inadvertently called
PlatformInit, which reset signal handling. This meant that our intentional
crash function ElectronBindings::Crash no longer worked and the renderer process
no longer crashed when process.crash() was called. We don't want to use Node.js'
default signal handling in the renderer process, so we disable it by passing
kNoDefaultSignalHandling to node::InitializeOncePerProcess.

* build: only create cppgc heap on non-32 bit platforms

* chore: clean up util:CompileAndCall

* src: fix compatility with upcoming V8 12.1 APIs

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

* fix: use thread_local BuiltinLoader

* chore: fixup v8 patch indices

---------

Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
This commit is contained in:
Shelley Vohr 2023-11-30 15:51:35 +01:00 коммит произвёл GitHub
Родитель 39ee94089a
Коммит 9c94fd7afb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
76 изменённых файлов: 1606 добавлений и 1789 удалений

Просмотреть файл

@ -29,6 +29,7 @@ import("filenames.gni")
import("filenames.hunspell.gni")
import("filenames.libcxx.gni")
import("filenames.libcxxabi.gni")
import("js2c_toolchain.gni")
if (is_mac) {
import("//build/config/mac/rules.gni")
@ -237,6 +238,7 @@ action("electron_js2c") {
":electron_sandboxed_renderer_bundle",
":electron_utility_bundle",
":electron_worker_bundle",
"//third_party/electron_node:node_js2c($electron_js2c_toolchain)",
]
sources = [
@ -249,13 +251,17 @@ action("electron_js2c") {
"$target_gen_dir/js2c/worker_init.js",
]
inputs = sources + [ "//third_party/electron_node/tools/js2c.py" ]
inputs = sources
outputs = [ "$root_gen_dir/electron_natives.cc" ]
script = "build/js2c.py"
args = [ rebase_path("//third_party/electron_node") ] +
rebase_path(outputs, root_build_dir) +
rebase_path(sources, root_build_dir)
out_dir =
get_label_info(":anything($electron_js2c_toolchain)", "root_out_dir")
args = [
rebase_path("$out_dir/node_js2c"),
rebase_path("$root_gen_dir"),
] + rebase_path(outputs, root_gen_dir) +
rebase_path(sources, root_gen_dir)
}
action("generate_config_gypi") {

2
DEPS
Просмотреть файл

@ -4,7 +4,7 @@ vars = {
'chromium_version':
'121.0.6147.0',
'node_version':
'v18.18.2',
'v20.9.0',
'nan_version':
'e14bdcd1f72d62bca1d541b66da43130384ec213',
'squirrel.mac_version':

30
build/js2c.py Executable file → Normal file
Просмотреть файл

@ -4,32 +4,14 @@ import os
import subprocess
import sys
TEMPLATE = """
#include "node_native_module.h"
#include "node_internals.h"
namespace node::native_module {{
{definitions}
void NativeModuleLoader::LoadEmbedderJavaScriptSource() {{
{initializers}
}}
}} // namespace node::native_module
"""
def main():
node_path = os.path.abspath(sys.argv[1])
natives = os.path.abspath(sys.argv[2])
js_source_files = sys.argv[3:]
js2c = sys.argv[1]
root = sys.argv[2]
natives = sys.argv[3]
js_source_files = sys.argv[4:]
js2c = os.path.join(node_path, 'tools', 'js2c.py')
subprocess.check_call(
[sys.executable, js2c] +
js_source_files +
['--only-js', '--target', natives])
[js2c, natives] + js_source_files + ['--only-js', "--root", root])
if __name__ == '__main__':
sys.exit(main())
sys.exit(main())

Просмотреть файл

@ -1,10 +1,11 @@
import sys
import os
import subprocess
def main(argv):
cwd = argv[1]
os.chdir(cwd)
os.execv(sys.executable, [sys.executable] + argv[2:])
os.chdir(argv[1])
p = subprocess.Popen(argv[2:])
return p.wait()
if __name__ == '__main__':
main(sys.argv)
sys.exit(main(sys.argv))

71
js2c_toolchain.gni Normal file
Просмотреть файл

@ -0,0 +1,71 @@
# Copyright (c) 2023 Microsoft, GmbH
# Use of this source code is governed by the MIT license that can be
# found in the LICENSE file.
declare_args() {
electron_js2c_toolchain = ""
}
if (electron_js2c_toolchain == "") {
if (current_os == host_os && current_cpu == host_cpu) {
# This is not a cross-compile, so build the snapshot with the current
# toolchain.
electron_js2c_toolchain = current_toolchain
} else if (current_os == host_os && current_cpu == "x86" &&
host_cpu == "x64") {
# This is an x64 -> x86 cross-compile, but x64 hosts can usually run x86
# binaries built for the same OS, so build the snapshot with the current
# toolchain here, too.
electron_js2c_toolchain = current_toolchain
} else if (current_os == host_os && host_cpu == "arm64" &&
current_cpu == "arm") {
# Trying to compile 32-bit arm on arm64. Good luck!
electron_js2c_toolchain = current_toolchain
} else if (host_cpu == current_cpu) {
# Cross-build from same ISA on one OS to another. For example:
# * targeting win/x64 on a linux/x64 host
# * targeting win/arm64 on a mac/arm64 host
electron_js2c_toolchain = host_toolchain
} else if (host_cpu == "arm64" && current_cpu == "x64") {
# Cross-build from arm64 to intel (likely on an Apple Silicon mac).
electron_js2c_toolchain =
"//build/toolchain/${host_os}:clang_arm64_v8_$current_cpu"
} else if (host_cpu == "x64") {
# This is a cross-compile from an x64 host to either a non-Intel target
# cpu or to 32-bit x86 on a different target OS.
assert(current_cpu != "x64", "handled by host_cpu == current_cpu branch")
if (current_cpu == "x86") {
_cpus = current_cpu
} else if (current_cpu == "arm64") {
if (is_win) {
# set _cpus to blank for Windows ARM64 so host_toolchain could be
# selected as snapshot toolchain later.
_cpus = ""
} else {
_cpus = "x64_v8_${current_cpu}"
}
} else if (current_cpu == "arm") {
_cpus = "x86_v8_${current_cpu}"
} else {
# This branch should not be reached; leave _cpus blank so the assert
# below will fail.
_cpus = ""
}
if (_cpus != "") {
electron_js2c_toolchain = "//build/toolchain/${host_os}:clang_${_cpus}"
} else if (is_win && current_cpu == "arm64") {
# cross compile Windows arm64 with host toolchain.
electron_js2c_toolchain = host_toolchain
}
} else if (host_cpu == "arm64" && current_cpu == "arm64" &&
host_os == "mac") {
# cross compile iOS arm64 with host_toolchain
electron_js2c_toolchain = host_toolchain
}
}
assert(electron_js2c_toolchain != "",
"Do not know how to build js2c for $current_toolchain " +
"on $host_os $host_cpu")

Просмотреть файл

@ -58,7 +58,7 @@ require('@electron/internal/renderer/common-init');
if (nodeIntegration) {
// Export node bindings to global.
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers');
const { makeRequireFunction } = __non_webpack_require__('internal/modules/helpers');
global.module = new Module('electron/js2c/renderer_init');
global.require = makeRequireFunction(global.module);

Просмотреть файл

@ -16,7 +16,7 @@ require('@electron/internal/common/init');
const { hasSwitch, getSwitchValue } = process._linkedBinding('electron_common_command_line');
// Export node bindings to global.
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers');
const { makeRequireFunction } = __non_webpack_require__('internal/modules/helpers');
global.module = new Module('electron/js2c/worker_init');
global.require = makeRequireFunction(global.module);

Просмотреть файл

@ -9,7 +9,7 @@
},
"dependencies": {
"@electron/get": "^2.0.0",
"@types/node": "^18.11.18",
"@types/node": "^20.9.0",
"extract-zip": "^2.0.1"
},
"engines": {

Просмотреть файл

@ -23,7 +23,7 @@
"@types/klaw": "^3.0.1",
"@types/minimist": "^1.2.0",
"@types/mocha": "^7.0.2",
"@types/node": "^18.11.18",
"@types/node": "^20.9.0",
"@types/semver": "^7.3.3",
"@types/send": "^0.14.5",
"@types/split": "^1.0.0",

Просмотреть файл

@ -17,15 +17,10 @@ fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch
fix_serdes_test.patch
feat_add_knostartdebugsignalhandler_to_environment_to_prevent.patch
feat_add_uv_loop_interrupt_on_io_change_option_to_uv_loop_configure.patch
json_parse_errors_made_user-friendly.patch
support_v8_sandboxed_pointers.patch
build_ensure_v8_pointer_compression_sandbox_is_enabled_on_64bit.patch
build_ensure_native_module_compilation_fails_if_not_using_a_new.patch
fix_override_createjob_in_node_platform.patch
v8_api_advance_api_deprecation.patch
fix_parallel_test-v8-stats.patch
fix_expose_the_built-in_electron_module_via_the_esm_loader.patch
api_pass_oomdetails_to_oomerrorcallback.patch
fix_expose_lookupandcompile_with_parameters.patch
enable_crashpad_linux_node_processes.patch
fix_lazyload_fs_in_esm_loaders_to_apply_asar_patches.patch
@ -38,21 +33,18 @@ fix_wunreachable-code_warning_in_ares_init_rand_engine.patch
fix_-wshadow_warning.patch
fix_do_not_resolve_electron_entrypoints.patch
fix_ftbfs_werror_wextra-semi.patch
fix_isurl_implementation.patch
ci_ensure_node_tests_set_electron_run_as_node.patch
fix_assert_module_in_the_renderer_process.patch
src_cast_v8_object_getinternalfield_return_value_to_v8_value.patch
fix_add_trusted_space_and_trusted_lo_space_to_the_v8_heap.patch
tls_ensure_tls_sockets_are_closed_if_the_underlying_wrap_closes.patch
test_deflake_test-tls-socket-close.patch
net_fix_crash_due_to_simultaneous_close_shutdown_on_js_stream.patch
net_use_asserts_in_js_socket_stream_to_catch_races_in_future.patch
lib_fix_broadcastchannel_initialization_location.patch
src_adapt_to_v8_exception_api_change.patch
lib_test_do_not_hardcode_buffer_kmaxlength.patch
fix_handle_possible_disabled_sharedarraybuffer.patch
win_process_avoid_assert_after_spawning_store_app_4152.patch
test_fix_edge_snapshot_stack_traces.patch
chore_remove_use_of_deprecated_kmaxlength.patch
api_remove_allcan_read_write.patch
fix_avx_detection.patch
src_avoid_copying_string_in_fs_permission.patch
fix_missing_include_for_node_extern.patch
feat_optionally_prevent_calling_v8_enablewebassemblytraphandler.patch
build_only_create_cppgc_heap_on_non-32_bit_platforms.patch
src_fix_compatility_with_upcoming_v8_12_1_apis.patch

Просмотреть файл

@ -1,38 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 12 Oct 2022 21:25:49 +0200
Subject: Pass OOMDetails to OOMErrorCallback
Introduced in https://chromium-review.googlesource.com/c/v8/v8/+/3647827.
This patch can be removed when Electron updates to Node.js v20.
diff --git a/src/node_errors.cc b/src/node_errors.cc
index e58e45be7bbb642f2277361d6312d444cfa27d16..54402bd5663666425b17fd267ba05ba7b800791c 100644
--- a/src/node_errors.cc
+++ b/src/node_errors.cc
@@ -521,9 +521,9 @@ static void ReportFatalException(Environment* env,
ABORT();
}
-[[noreturn]] void OOMErrorHandler(const char* location, bool is_heap_oom) {
+[[noreturn]] void OOMErrorHandler(const char* location, const v8::OOMDetails& details) {
const char* message =
- is_heap_oom ? "Allocation failed - JavaScript heap out of memory"
+ details.is_heap_oom ? "Allocation failed - JavaScript heap out of memory"
: "Allocation failed - process out of memory";
if (location) {
FPrintF(stderr, "FATAL ERROR: %s %s\n", location, message);
diff --git a/src/node_errors.h b/src/node_errors.h
index cc336536af0170e63cf9ccde99f9fa0a0be3f216..1687eed35717ae385aedad952c03ebab4f0f3bf7 100644
--- a/src/node_errors.h
+++ b/src/node_errors.h
@@ -21,7 +21,7 @@ void AppendExceptionLine(Environment* env,
[[noreturn]] void FatalError(const char* location, const char* message);
[[noreturn]] void OnFatalError(const char* location, const char* message);
-[[noreturn]] void OOMErrorHandler(const char* location, bool is_heap_oom);
+[[noreturn]] void OOMErrorHandler(const char* location, const v8::OOMDetails& details);
// Helpers to construct errors similar to the ones provided by
// lib/internal/errors.js.

Просмотреть файл

@ -1,22 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Fri, 10 Nov 2023 14:22:04 +0900
Subject: Remove AllCan Read/Write
Refs https://chromium-review.googlesource.com/c/v8/v8/+/5006387
Patch will be removed once upstream lands the relevant v8 roll.
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 10b821119d3ff2dd112d6cde195f65a2c34b4a2d..22eac1c65eab1bd632f461fa2fdfb917cc63dc1a 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -928,8 +928,7 @@ napi_define_class(napi_env env,
tpl->PrototypeTemplate()->SetAccessorProperty(property_name,
getter_tpl,
setter_tpl,
- attributes,
- v8::AccessControl::DEFAULT);
+ attributes);
} else if (p->method != nullptr) {
v8::Local<v8::FunctionTemplate> t;
STATUS_CALL(v8impl::FunctionCallbackWrapper::NewTemplate(

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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 62cb46b328871d929f16ced2a4741bc6e6b004db..53ab7c255317d2280e2579435bc7097705f19c6e 100644
index a04a4a4e108862b64725345beaba73ad6f69eb51..f1c36cfd697485564f0fe7998eaf924aa30f140b 100644
--- a/common.gypi
+++ b/common.gypi
@@ -79,6 +79,8 @@
@ -40,10 +40,10 @@ index 62cb46b328871d929f16ced2a4741bc6e6b004db..53ab7c255317d2280e2579435bc70977
'defines': [
'V8_COMPRESS_POINTERS',
diff --git a/configure.py b/configure.py
index 875d83e5db0037b902cff03c74852ea347513b03..8776cd057607ffe913bdd822a0aed5f9f1aa4a7a 100755
index 7b80ec63a082ce93ba81ca6dd41ec03041534ff7..926659883d3bd6d447c89a50d6770988b59d6f88 100755
--- a/configure.py
+++ b/configure.py
@@ -1524,6 +1524,7 @@ def configure_library(lib, output, pkgname=None):
@@ -1484,6 +1484,7 @@ def configure_library(lib, output, pkgname=None):
def configure_v8(o):
@ -52,7 +52,7 @@ index 875d83e5db0037b902cff03c74852ea347513b03..8776cd057607ffe913bdd822a0aed5f9
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 c4cce244359d893acf31e78f935152d4d47b14cd..26368061a909e6abc62a4cf261a5dbbd79404f1a 100644
index 99d2e1384df4000d4e1f1ffeafa83d29a152054b..9ac0d5addcdd40d5c91d375b626099b95729548a 100644
--- a/src/node.h
+++ b/src/node.h
@@ -22,6 +22,12 @@

Просмотреть файл

@ -8,7 +8,7 @@ Aligns common.gypi with the current build flag state of //v8.
Specifically enables `V8_ENABLE_SANDBOX`, `V8_SANDBOXED_POINTERS`, `V8_COMPRESS_POINTERS` and `V8_COMPRESS_POINTERS_IN_SHARED_CAGE`.
diff --git a/common.gypi b/common.gypi
index 10d11f1e9aacfbe4bb53e1220afab1e68db98313..62cb46b328871d929f16ced2a4741bc6e6b004db 100644
index 0b073571cd482d5124123c4490c564f839429b28..a04a4a4e108862b64725345beaba73ad6f69eb51 100644
--- a/common.gypi
+++ b/common.gypi
@@ -65,6 +65,7 @@
@ -42,10 +42,10 @@ index 10d11f1e9aacfbe4bb53e1220afab1e68db98313..62cb46b328871d929f16ced2a4741bc6
'defines': ['V8_31BIT_SMIS_ON_64BIT_ARCH'],
}],
diff --git a/configure.py b/configure.py
index 7006ee65816989976b1648374565ebbae4b188f1..875d83e5db0037b902cff03c74852ea347513b03 100755
index 62f041ce52bf85136175e733216671e2811a337b..7b80ec63a082ce93ba81ca6dd41ec03041534ff7 100755
--- a/configure.py
+++ b/configure.py
@@ -1537,6 +1537,7 @@ def configure_v8(o):
@@ -1497,6 +1497,7 @@ def configure_v8(o):
o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1
o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0
o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0

Просмотреть файл

@ -4,23 +4,20 @@ Date: Thu, 11 Apr 2019 17:16:13 +0900
Subject: build: modify js2c.py to allow injection of original-fs and custom
embedder JS
This patch does two things:
* Updates js2c.py so that original-fs is automatically created with
support for streams by copying the file at build time and making a new
builtin called "original-fs" and "original-fs/streams"
* Updates js2c.py so that //electron can call it as part of its build
process and provide embedder modules (electrons
renderer/browser/worker/sandboxed bootstrap scripts). These are loaded
through LoadEmbedderJavaScriptSource()
This patch ensures that internal/fs/watchers can be loaded twice without
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 ce885c154c81c5703365fa34957697698da9aff6..229b0d522aeee3632145c86715bea1394d496bc4 100644
index 99212fa713bf3f767d4604906e41d9b279447239..4e32a274a63c8244ce3168d0c5cc56203cfe5473 100644
--- a/lib/internal/fs/watchers.js
+++ b/lib/internal/fs/watchers.js
@@ -293,11 +293,13 @@ function emitCloseNT(self) {
@@ -292,12 +292,13 @@ function emitCloseNT(self) {
}
// Legacy alias on the C++ wrapper object. This is not public API, so we may
// want to runtime-deprecate it at some point. There's no hurry, though.
-// want to runtime-deprecate it at some point. There's no hurry, though.
-ObjectDefineProperty(FSEvent.prototype, 'owner', {
- __proto__: null,
- get() { return this[owner_symbol]; },
@ -34,159 +31,29 @@ index ce885c154c81c5703365fa34957697698da9aff6..229b0d522aeee3632145c86715bea139
+ });
+}
async function* watch(filename, options = kEmptyObject) {
const path = toNamespacedPath(getValidatedPath(filename));
let kResistStopPropagation;
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 356ec3acd0bf3ac1e7518b32a5a58b042a03f598..4d4b59916bfdb203702c4e878ff2659b79de8c52 100644
index 80b36dc1aefca4d5d4124d7f84b12b9762a8de2c..f3cda64beaa1403cb33f1b0bd8089f3dfcbfc8b9 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -33,6 +33,7 @@ BuiltinLoader BuiltinLoader::instance_;
BuiltinLoader::BuiltinLoader() : config_(GetConfig()), has_code_cache_(false) {
@@ -35,6 +35,7 @@ using v8::Value;
BuiltinLoader::BuiltinLoader()
: config_(GetConfig()), code_cache_(std::make_shared<BuiltinCodeCache>()) {
LoadJavaScriptSource();
+ LoadEmbedderJavaScriptSource();
#ifdef NODE_SHARED_BUILTIN_CJS_MODULE_LEXER_LEXER_PATH
AddExternalizedBuiltin(
"internal/deps/cjs-module-lexer/lexer",
diff --git a/src/node_builtins.h b/src/node_builtins.h
index 90b158b84bb2a66781cf92f5b4c1a64f9e2ee651..8d9f7c409659a30747e5feeac6cfec4208791370 100644
index ea77c7598153bb8a9ba20c89a4ece2c1580b9a25..11d10f52b7c492bfae4bc58b39c20a693762a72d 100644
--- a/src/node_builtins.h
+++ b/src/node_builtins.h
@@ -71,6 +71,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
@@ -126,6 +126,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
// Generated by tools/js2c.py as node_javascript.cc
void LoadJavaScriptSource(); // Loads data into source_
+ void LoadEmbedderJavaScriptSource(); // Loads embedder data into source_
UnionBytes GetConfig(); // Return data for config.gypi
std::vector<std::string> GetBuiltinIds();
diff --git a/tools/js2c.py b/tools/js2c.py
index 077bba1572f05f1aa16553894703b12abc19a985..bb9f26e3adc863757ad8ede5069d299c2d138369 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -39,6 +39,8 @@ import codecs
import utils
def ReadFile(filename):
+ if filename.startswith("//v8"):
+ filename = "../../" + filename[2:]
if is_verbose:
print(filename)
with codecs.open(filename, "r", "utf-8") as f:
@@ -57,13 +59,15 @@ namespace builtins {{
{0}
-void BuiltinLoader::LoadJavaScriptSource() {{
+void BuiltinLoader::Load{4}JavaScriptSource() {{
{1}
}}
+#if {2}
UnionBytes BuiltinLoader::GetConfig() {{
- return UnionBytes(config_raw, {2}); // config.gypi
+ return UnionBytes(config_raw, {3}); // config.gypi
}}
+#endif
}} // namespace builtins
@@ -113,8 +117,8 @@ def GetDefinition(var, source, step=30):
return definition, len(code_points)
-def AddModule(filename, definitions, initializers):
- code = ReadFile(filename)
+def AddModule(filename, definitions, initializers, ReadFileFn=ReadFile):
+ code = ReadFileFn(filename)
name = NormalizeFileName(filename)
slug = SLUGGER_RE.sub('_', name)
var = slug + '_raw'
@@ -124,7 +128,9 @@ def AddModule(filename, definitions, initializers):
initializers.append(initializer)
def NormalizeFileName(filename):
- split = filename.split('/')
+ if filename.startswith('//v8'):
+ filename = "deps/" + filename[2:]
+ split = os.path.normpath(filename).split(os.path.sep)
if split[0] == 'deps':
split = ['internal'] + split
else: # `lib/**/*.js` so drop the 'lib' part
@@ -142,23 +148,36 @@ def NormalizeFileName(filename):
return os.path.splitext(filename)[0]
-def JS2C(source_files, target):
+def JS2C(source_files, target, only_js):
# Build source code lines
definitions = []
initializers = []
- for filename in source_files['.js']:
- AddModule(filename, definitions, initializers)
- for filename in source_files['.mjs']:
- AddModule(filename, definitions, initializers)
-
- config_def, config_size = handle_config_gypi(source_files['config.gypi'])
- definitions.append(config_def)
+ for extension in source_files.keys():
+ if extension == '.js' or extension == '.mjs':
+ for filename in source_files[extension]:
+ AddModule(filename, definitions, initializers)
+
+ # Electron: Expose fs module without asar support.
+ if filename == 'lib/fs.js':
+ # Node's 'fs' and 'internal/fs/<filename> have lazy-loaded circular
+ # dependencies. So to expose the unmodified Node 'fs' functionality here,
+ # we have to copy both 'fs' *and* 'internal/fs/<filename>' files and modify the
+ # copies to depend on each other instead of on our asarified 'fs' code.
+ AddModule('lib/original-fs.js', definitions, initializers, lambda _: ReadFile(filename).replace("require('internal/fs/", "require('internal/original-fs/"))
+ elif filename.startswith('lib/internal/fs/'):
+ original_fs_filename = filename.replace('internal/fs/', 'internal/original-fs/')
+ AddModule(original_fs_filename, definitions, initializers, lambda _: ReadFile(filename).replace("require('fs')", "require('original-fs')"))
+
+ config_size = 0
+ if not only_js:
+ config_def, config_size = handle_config_gypi(source_files['config.gypi'])
+ definitions.append(config_def)
# Emit result
definitions = ''.join(definitions)
initializers = '\n '.join(initializers)
- out = TEMPLATE.format(definitions, initializers, config_size)
+ out = TEMPLATE.format(definitions, initializers, '0' if only_js else '1', config_size, 'Embedder' if only_js else '')
write_if_chaged(out, target)
@@ -222,6 +241,7 @@ def main():
default=None,
help='root directory containing the sources')
parser.add_argument('--verbose', action='store_true', help='output file')
+ parser.add_argument('--only-js', action='store_true', help='do not require or parse any config.gypi files')
parser.add_argument('sources', nargs='*', help='input files')
options = parser.parse_args()
global is_verbose
@@ -238,13 +258,15 @@ def main():
source_files = functools.reduce(SourceFileByExt, sources, {})
- # Should have exactly 3 types: `.js`, `.mjs` and `.gypi`
- assert len(source_files) == 3
- # Currently config.gypi is the only `.gypi` file allowed
- assert len(source_files['.gypi']) == 1
- assert os.path.basename(source_files['.gypi'][0]) == 'config.gypi'
- source_files['config.gypi'] = source_files.pop('.gypi')[0]
- JS2C(source_files, options.target)
+ if options.only_js:
+ assert len(source_files) == 1
+ else:
+ # Should have exactly 3 types: `.js`, `.mjs` and `.gypi`
+ assert len(source_files) == 3
+ # Currently config.gypi is the only `.gypi` file allowed
+ assert source_files['.gypi'][0].endswith('config.gypi')
+ source_files['config.gypi'] = source_files.pop('.gypi')[0]
+ JS2C(source_files, options.target, options.only_js)
if __name__ == "__main__":
std::vector<std::string_view> GetBuiltinIds() const;

Просмотреть файл

@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 27 Nov 2023 17:23:29 +0100
Subject: build: only create cppgc heap on non-32 bit platforms
Node.js crashes during heap marking when using cppgc on 32 bit platforms. Disable for now.
Crash occurs in the following stack:
* MarkingVisitorBase<ConcreteVisitor>::VisitEmbedderTracingSubClassWithEmbedderTracing
* MarkingWorklists::Local::PushExtractedWrapper
* CppMarkingState::MarkAndPush
* CppMarkingState::MarkAndPush
* WrappableInfo::From
* Crash
See https://gist.github.com/codebytere/275ec8923253fd6559b3d36115f7b31b for more.
This should be fixed and re-enabled on all platforms.
diff --git a/BUILD.gn b/BUILD.gn
index 24c122008e0fc009833cf9189ebf43883207c754..1f0263b06969e099a5b3aaf09d36a66c43dd80fc 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -178,6 +178,10 @@ config("node_internal_config") {
}
defines += [ "NODE_ARCH=\"$node_arch\"" ]
+ if (target_cpu == "x86" || target_cpu == "arm") {
+ defines += [ "NODE_RUNNING_32_BIT" ]
+ }
+
if (target_os == "win") {
node_platform = "win32"
} else if (target_os == "mac") {
diff --git a/src/env.cc b/src/env.cc
index 1d8df40c3446ac9c72c5f0ad24edf0b8a96cf16b..25b81dee18aeeb1bd0452ba0b66085d451723709 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -542,7 +542,8 @@ IsolateData::IsolateData(Isolate* isolate,
// for embedder ID, V8 could accidentally enable cppgc on them. So
// safe guard against this.
DCHECK_NE(descriptor.wrappable_type_index, BaseObject::kSlot);
- } else {
+ } else {
+#if !defined(NODE_RUNNING_32_BIT)
cpp_heap_ = CppHeap::Create(
platform,
CppHeapCreateParams{
@@ -550,6 +551,7 @@ IsolateData::IsolateData(Isolate* isolate,
WrapperDescriptor(
BaseObject::kEmbedderType, BaseObject::kSlot, cppgc_id)});
isolate->AttachCppHeap(cpp_heap_.get());
+#endif
}
// We do not care about overflow since we just want this to be different
// from the cppgc id.

Просмотреть файл

@ -8,7 +8,7 @@ modules from being used in the renderer process. This should be upstreamed as
a customizable error message.
diff --git a/src/node_binding.cc b/src/node_binding.cc
index a82763cc5ad47f25b63b8c72e08bdc09ab841448..eb25fb4a81f53e2e443d0276bb1acbbf5700533a 100644
index 8cdee730101fbdc79415654aa6fe401573979c0e..34d5e146ffef255019dd33d8c23b0847d91ddee9 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -4,6 +4,7 @@
@ -19,7 +19,7 @@ index a82763cc5ad47f25b63b8c72e08bdc09ab841448..eb25fb4a81f53e2e443d0276bb1acbbf
#include "util.h"
#include <string>
@@ -481,7 +482,12 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
@@ -480,7 +481,12 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
if (mp->nm_context_register_func == nullptr) {
if (env->force_context_aware()) {
dlib->Close();

Просмотреть файл

@ -8,10 +8,10 @@ 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 001343b74ce236f89dca030c0fc9dd0299df0b39..6f277daf4ce846f093f634c473daec07939b4558 100644
index 84fea979d482d3d5cacfad4b09237e6345675cad..678ed0a7b43c30c5dd6102d83f490e23c95090ce 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -1230,6 +1230,13 @@ Module.prototype._compile = function(content, filename) {
@@ -1215,6 +1215,13 @@ Module.prototype._compile = function(content, filename) {
if (getOptionValue('--inspect-brk') && process._eval == null) {
if (!resolvedArgv) {
// We enter the repl if we're not given a filename argument.
@ -26,10 +26,10 @@ index 001343b74ce236f89dca030c0fc9dd0299df0b39..6f277daf4ce846f093f634c473daec07
try {
resolvedArgv = Module._resolveFilename(process.argv[1], null, false);
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index fcbd9ee1af002bc176937e6bb5af55791b2f64b2..cbfb6e3620a7e77658c86a4730c50661b8a937f7 100644
index 0dc769846b4e6fe84438cd6d8024c4a89eb90a9b..bff9bdc7ad58183e9eb04ee45b76592b4240952a 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -164,11 +164,13 @@ function patchProcessObject(expandArgv1) {
@@ -204,11 +204,13 @@ function patchProcessObject(expandArgv1) {
if (expandArgv1 && process.argv[1] &&
!StringPrototypeStartsWith(process.argv[1], '-')) {
// Expand process.argv[1] into a full path.

Просмотреть файл

@ -10,32 +10,37 @@ its own blended handler between Node and Blink.
Not upstreamable.
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index cbfb6e3620a7e77658c86a4730c50661b8a937f7..ccd48027e3dfebd563fcbe83239174c79c693dd7 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -567,7 +567,7 @@ function initializeESMLoader() {
// Create this WeakMap in js-land because V8 has no C++ API for WeakMap.
internalBinding('module_wrap').callbackMap = new SafeWeakMap();
- if (getEmbedderOptions().shouldNotRegisterESMLoader) return;
diff --git a/lib/internal/modules/esm/utils.js b/lib/internal/modules/esm/utils.js
index 985784383024450833a8324d45a7af2fe214a09c..356c10aef57454be3b4607156606784f473042cf 100644
--- a/lib/internal/modules/esm/utils.js
+++ b/lib/internal/modules/esm/utils.js
@@ -16,7 +16,7 @@ const {
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
ERR_INVALID_ARG_VALUE,
} = require('internal/errors').codes;
-const { getOptionValue } = require('internal/options');
+const { getOptionValue, getEmbedderOptions } = require('internal/options');
const {
loadPreloadModules,
initializeFrozenIntrinsics,
@@ -148,12 +148,13 @@ async function importModuleDynamicallyCallback(symbol, specifier, assertions) {
// the loader worker in internal/main/worker_thread.js.
let _isLoaderWorker = false;
function initializeESM(isLoaderWorker = false) {
+ const shouldSetOnIsolate = !getEmbedderOptions().shouldNotRegisterESMLoader;
const {
setImportModuleDynamicallyCallback,
@@ -576,8 +576,8 @@ function initializeESMLoader() {
const esm = require('internal/process/esm_loader');
_isLoaderWorker = isLoaderWorker;
initializeDefaultConditions();
// Setup per-isolate callbacks that locate data or callbacks that we keep
// track of for different ESM modules.
- setInitializeImportMetaObjectCallback(esm.initializeImportMetaObject);
- setImportModuleDynamicallyCallback(esm.importModuleDynamicallyCallback);
+ setInitializeImportMetaObjectCallback(esm.initializeImportMetaObject, shouldSetOnIsolate);
+ setImportModuleDynamicallyCallback(esm.importModuleDynamicallyCallback, shouldSetOnIsolate);
- setInitializeImportMetaObjectCallback(initializeImportMetaObject);
- setImportModuleDynamicallyCallback(importModuleDynamicallyCallback);
+ setInitializeImportMetaObjectCallback(initializeImportMetaObject, shouldSetOnIsolate);
+ setImportModuleDynamicallyCallback(importModuleDynamicallyCallback, shouldSetOnIsolate);
}
// Patch the vm module when --experimental-vm-modules is on.
// Please update the comments in vm.js when this block changes.
function isLoaderWorker() {
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 0645b3ddf506df2a76f5661f0ec6bb35d5d8b94e..e0f1b2d51f3055b2250f2c0dc1dfd1048b645dd9 100644
index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29a3ac678f 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -547,7 +547,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
@ -47,7 +52,7 @@ index 0645b3ddf506df2a76f5661f0ec6bb35d5d8b94e..e0f1b2d51f3055b2250f2c0dc1dfd104
Local<Context> context,
Local<v8::Data> host_defined_options,
Local<Value> resource_name,
@@ -629,12 +629,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
@@ -610,12 +610,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
Environment* env = Environment::GetCurrent(args);
HandleScope handle_scope(isolate);
@ -63,7 +68,7 @@ index 0645b3ddf506df2a76f5661f0ec6bb35d5d8b94e..e0f1b2d51f3055b2250f2c0dc1dfd104
}
void ModuleWrap::HostInitializeImportMetaObjectCallback(
@@ -665,13 +666,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
@@ -652,13 +653,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
@ -82,11 +87,11 @@ index 0645b3ddf506df2a76f5661f0ec6bb35d5d8b94e..e0f1b2d51f3055b2250f2c0dc1dfd104
MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(
diff --git a/src/module_wrap.h b/src/module_wrap.h
index 58b233d036515c52d9bd5574c776c2ea65d2ecb1..5f7ef75480a76761c6fa62061c8700c812a3fc6f 100644
index 6435bad40936fe235822c0597310b94ab98082f3..c51eb99ce3eb54bc30ae922e0357b637b09d53c6 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -30,7 +30,14 @@ enum HostDefinedOptions : int {
kLength = 10,
kLength = 9,
};
-class ModuleWrap : public BaseObject {
@ -100,4 +105,4 @@ index 58b233d036515c52d9bd5574c776c2ea65d2ecb1..5f7ef75480a76761c6fa62061c8700c8
+class NODE_EXTERN ModuleWrap : public BaseObject {
public:
enum InternalFields {
kModuleWrapBaseField = BaseObject::kInternalFieldCount,
kModuleSlot = BaseObject::kInternalFieldCount,

Просмотреть файл

@ -9,7 +9,7 @@ This patch can be removed when Node.js upgrades to a version of V8 containing
the above CL.
diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml
index 3b406703ce9f981411cd9de5379f8574384e170a..bc439ce0aa072a778a22ba860eed35263740a1cd 100644
index 942d7cc1305eb4cf327de5666551435802f0dbac..991c65215488b9526758b9aca96842ad17fc018e 100644
--- a/lib/.eslintrc.yaml
+++ b/lib/.eslintrc.yaml
@@ -33,10 +33,6 @@ rules:
@ -24,10 +24,10 @@ index 3b406703ce9f981411cd9de5379f8574384e170a..bc439ce0aa072a778a22ba860eed3526
message: Use `const { Blob } = require('buffer');` instead of the global.
- name: BroadcastChannel
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
index 7fbfb64984c290a1d71c99c92084975c31ce18fe..be4d82086199855a10108528b3dacc663b839454 100644
index 12ae4a9b23212d3f8ff1566a1c2b815a47d3838a..4460042d7bfbb8286a9b2abcbfb9e44f21b5d944 100644
--- a/lib/internal/main/worker_thread.js
+++ b/lib/internal/main/worker_thread.js
@@ -108,7 +108,7 @@ port.on('message', (message) => {
@@ -112,7 +112,7 @@ port.on('message', (message) => {
require('internal/worker').assignEnvironmentData(environmentData);
@ -37,10 +37,10 @@ index 7fbfb64984c290a1d71c99c92084975c31ce18fe..be4d82086199855a10108528b3dacc66
// not to workers created by other workers.
let cachedCwd = '';
diff --git a/lib/internal/worker.js b/lib/internal/worker.js
index 3d828d2f6f2b19554f7fc01ea880c0c144d8837d..78fcaec8d694580798783c83c3282ec1aaac4aa7 100644
index 401bc43550ea7f19847dfd588e3fba0507243905..560f69c6c2de2bd976bcd62cd7ac9c770b838446 100644
--- a/lib/internal/worker.js
+++ b/lib/internal/worker.js
@@ -93,8 +93,7 @@ let cwdCounter;
@@ -101,8 +101,7 @@ let cwdCounter;
const environmentData = new SafeMap();
// SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.

Просмотреть файл

@ -21,10 +21,10 @@ index 606a6f5caa3b11b6d2a9068ed2fd65800530a5eb..080dcce21da05ccea398d8a856deb397
typedef void (*FreeCallback)(char* data, void* hint);
diff --git a/src/node_errors.h b/src/node_errors.h
index 1687eed35717ae385aedad952c03ebab4f0f3bf7..4cd96bf9dd721ec24dd5f23086da5b72be58d0a9 100644
index 569dafe82df83db02d93b0e58231ef804eb54be8..c6b8c3b5b36ea25a31bdf3c6a48ef20f3c1b6577 100644
--- a/src/node_errors.h
+++ b/src/node_errors.h
@@ -208,7 +208,7 @@ inline v8::Local<v8::Value> ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) {
@@ -218,7 +218,7 @@ inline v8::Local<v8::Value> ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) {
char message[128];
snprintf(message, sizeof(message),
"Cannot create a Buffer larger than 0x%zx bytes",

Просмотреть файл

@ -8,10 +8,10 @@ which causes the `ELECTRON_RUN_AS_NODE` variable to be lost. This patch
re-injects it.
diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js
index c403751ac3ef5e39e7c0b1a1a8fb704ebf843dd7..83ee45f5f906adddcbc701112f373332dd1f66f9 100644
index 0bd0fc18534f8b3106b79a010dfc4ffe0ab17ec3..838ee86f74ea89e052676a5c25e23481369857fa 100644
--- a/test/common/assertSnapshot.js
+++ b/test/common/assertSnapshot.js
@@ -62,6 +62,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
@@ -76,6 +76,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
const flags = common.parseTestFlags(filename);
const executable = tty ? 'tools/pseudo-tty.py' : process.execPath;
const args = tty ? [process.execPath, ...flags, filename] : [...flags, filename];
@ -47,14 +47,14 @@ index 5a1b9feb6c8bedb50b89f5c4f3c5983455bb042d..efca7811dc0b6a590c5ee023c7180170
});
}
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
index fca2149fea32123dc4d4c6f21c64cc3c583454b3..b9a55fb7ea22e62553f69bd035797f7aaee1fc38 100644
index 4c4fc08c0cf3828d11aefe9f12318001bf10c16d..b08bcd40cdf26093e158c0bb9ae566c76f2c731e 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -53,6 +53,7 @@ describe('errors output', { concurrency: true }, () => {
!skipForceColors ? { name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } } : null,
].filter(Boolean);
for (const { name, transform, env } of tests) {
+ if (env) env.ELECTRON_RUN_AS_NODE = 1;
it(name, async () => {
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { env });
@@ -61,6 +61,7 @@ describe('errors output', { concurrency: true }, () => {
];
for (const { name, transform = defaultTransform, env, skip = false } of tests) {
it(name, { skip }, async () => {
+ if (env) env.ELECTRON_RUN_AS_NODE = 1;
await snapshot.spawnAndAssert(fixtures.path(name), transform, { env });
});
}

Просмотреть файл

@ -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 ec39a00ddb791e6e1ebe31aa45d290e7dcc4ebfc..1cd5d8969471b276211c45a9d8d76e9b10b1bb66 100644
index 9dd33ecbac3a5d516f9bff76fdbe1a8aece531f2..0464ecc7b53389cdff97a7fe4cb01582e8b72dbb 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -61,6 +61,7 @@ let debug = require('internal/util/debuglog').debuglog(

Просмотреть файл

@ -9,10 +9,10 @@ modules to sandboxed renderers.
TODO(codebytere): remove and replace with a public facing API.
diff --git a/src/node_binding.cc b/src/node_binding.cc
index 259ce86b4c443c960dae6cb1c9d6c62b9ff23b30..a82763cc5ad47f25b63b8c72e08bdc09ab841448 100644
index 97257d47c6173872e55facf6f92801bd2fc3564b..8cdee730101fbdc79415654aa6fe401573979c0e 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -620,6 +620,10 @@ void GetInternalBinding(const FunctionCallbackInfo<Value>& args) {
@@ -638,6 +638,10 @@ void GetInternalBinding(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(exports);
}
@ -24,10 +24,10 @@ index 259ce86b4c443c960dae6cb1c9d6c62b9ff23b30..a82763cc5ad47f25b63b8c72e08bdc09
Environment* env = Environment::GetCurrent(args);
diff --git a/src/node_binding.h b/src/node_binding.h
index 32106afb0b7260b297c0e1a94527e03ed6039ee0..62a7473f64a618bb631b08cd5a32a1bcaa296aa8 100644
index 9f0692ca4e190bde251d4825aa9abac3d66b6ac6..f4024a05901f72f85e097a8ab6ddbd5812e9ba16 100644
--- a/src/node_binding.h
+++ b/src/node_binding.h
@@ -98,6 +98,8 @@ void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -134,6 +134,8 @@ void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
void GetLinkedBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args);

Просмотреть файл

@ -7,10 +7,10 @@ Subject: feat: add kNoStartDebugSignalHandler to Environment to prevent
This patch should be upstreamed, it allows embedders to prevent the call to StartDebugSignalHandler which handles SIGUSR1 and starts the inspector agent. Apps that have --inspect disabled also don't want SIGUSR1 to have this affect.
diff --git a/src/env-inl.h b/src/env-inl.h
index 7ceab0da0c632f857f6e2d0fbf479bbc4f55df07..debd982c75805c51ea7d01229b9d635550060503 100644
index 793dc72e0dbad819a1c3a51521b4a39b76c7015d..222c78ef0cb9904742fd44f8182278ab1f50cd59 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -627,6 +627,10 @@ inline bool Environment::no_global_search_paths() const {
@@ -677,6 +677,10 @@ inline bool Environment::no_global_search_paths() const {
!options_->global_search_paths;
}
@ -22,10 +22,10 @@ index 7ceab0da0c632f857f6e2d0fbf479bbc4f55df07..debd982c75805c51ea7d01229b9d6355
// configure --no-browser-globals
#ifdef NODE_NO_BROWSER_GLOBALS
diff --git a/src/env.h b/src/env.h
index b67a476701f9bd8abdfc0ef9cfe800e84fb8f8c2..45a9a7811b4abe1effb6acf2c89a772a7c2256c9 100644
index afe67d2237ae6933de44dd1141cf388e9a48cee3..87df6e1f32e584aa0c6ae21856299fff31d67669 100644
--- a/src/env.h
+++ b/src/env.h
@@ -748,6 +748,7 @@ class Environment : public MemoryRetainer {
@@ -787,6 +787,7 @@ class Environment : public MemoryRetainer {
inline bool tracks_unmanaged_fds() const;
inline bool hide_console_windows() const;
inline bool no_global_search_paths() const;
@ -34,10 +34,10 @@ index b67a476701f9bd8abdfc0ef9cfe800e84fb8f8c2..45a9a7811b4abe1effb6acf2c89a772a
inline uint64_t thread_id() const;
inline worker::Worker* worker_context() const;
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index b1ba86b7b0b2349f771e01143630e45cf0aecc3b..4c9f7f636aeeb19a87150ac5a05e28159503f051 100644
index f0b4cc43c864aee1fab8e073ea110ea108c653ab..6d12e27b955fb9fddab24d846e563c969bb48ae7 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -703,8 +703,10 @@ bool Agent::Start(const std::string& path,
@@ -707,8 +707,10 @@ bool Agent::Start(const std::string& path,
StartIoThreadAsyncCallback));
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
start_io_thread_async.data = this;
@ -51,10 +51,10 @@ index b1ba86b7b0b2349f771e01143630e45cf0aecc3b..4c9f7f636aeeb19a87150ac5a05e2815
parent_env_->AddCleanupHook([](void* data) {
Environment* env = static_cast<Environment*>(data);
diff --git a/src/node.h b/src/node.h
index b50bd5a941d381778d464fdb2770566a3ac34fed..c4cce244359d893acf31e78f935152d4d47b14cd 100644
index dcce529664e1d126115545d6ba7f5b8492b0e921..99d2e1384df4000d4e1f1ffeafa83d29a152054b 100644
--- a/src/node.h
+++ b/src/node.h
@@ -575,7 +575,11 @@ enum Flags : uint64_t {
@@ -654,7 +654,11 @@ enum Flags : uint64_t {
// This control is needed by embedders who may not want to initialize the V8
// inspector in situations where one has already been created,
// e.g. Blink's in Chromium.

Просмотреть файл

@ -26,10 +26,10 @@ index 0f5ddfb3ca21b7e5b38d0a4ce4b9e77387597199..ba815202fb157aa82859ec0518523cf6
.. c:function:: int uv_loop_close(uv_loop_t* loop)
diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
index ee1c94ccd389915ea7572cce044256a7788025ad..d31abf714d5d1433ec8473ccb1aae3b6615c477a 100644
index 02397dd0fdd43d51f86c0dde9a62046702f12bdb..3375600023e39ddacf62cc17deb4f206db942084 100644
--- a/deps/uv/include/uv.h
+++ b/deps/uv/include/uv.h
@@ -252,7 +252,8 @@ typedef struct uv_statfs_s uv_statfs_t;
@@ -260,7 +260,8 @@ typedef struct uv_metrics_s uv_metrics_t;
typedef enum {
UV_LOOP_BLOCK_SIGNAL = 0,
@ -40,7 +40,7 @@ index ee1c94ccd389915ea7572cce044256a7788025ad..d31abf714d5d1433ec8473ccb1aae3b6
typedef enum {
diff --git a/deps/uv/src/unix/async.c b/deps/uv/src/unix/async.c
index e1805c323795e5b0c465d80100eebeb7bf838caa..dd4358c0cdaa97ba8fadf4d9755993803beddd18 100644
index 0ff2669e30a628dbb2df9e28ba14b38cf14114e5..117190ef26338944b78dbed7380c631de8057223 100644
--- a/deps/uv/src/unix/async.c
+++ b/deps/uv/src/unix/async.c
@@ -38,7 +38,6 @@
@ -49,18 +49,18 @@ index e1805c323795e5b0c465d80100eebeb7bf838caa..dd4358c0cdaa97ba8fadf4d975599380
-static void uv__async_send(uv_loop_t* loop);
static int uv__async_start(uv_loop_t* loop);
static void uv__cpu_relax(void);
@@ -70,7 +69,7 @@ int uv_async_send(uv_async_t* handle) {
return 0;
@@ -78,7 +77,7 @@ int uv_async_send(uv_async_t* handle) {
/* Wake up the other thread's event loop. */
- uv__async_send(handle->loop);
+ uv__loop_interrupt(handle->loop);
if (atomic_exchange(pending, 1) == 0)
- uv__async_send(handle->loop);
+ uv__loop_interrupt(handle->loop);
/* Tell the other thread we're done. */
if (cmpxchgi(&handle->pending, 1, 2) != 1)
@@ -165,40 +164,6 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
/* Set the loop to not-busy. */
atomic_fetch_add(busy, -1);
@@ -178,39 +177,6 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
}
@ -97,15 +97,14 @@ index e1805c323795e5b0c465d80100eebeb7bf838caa..dd4358c0cdaa97ba8fadf4d975599380
- abort();
-}
-
-
static int uv__async_start(uv_loop_t* loop) {
int pipefd[2];
int err;
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index 54c769f37f2331136c87a37c13fb4e3f9a8f22f9..ac52ab79a5fc3050effd2b1f2f605cee9b1ab336 100644
index 25c5181f370e94983e8a5f797f02f7a8dc207e00..f4d9059796d2c65339a5d48ecb273b09d9364d21 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -900,6 +900,9 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
@@ -926,6 +926,9 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
loop->watchers[w->fd] = w;
loop->nfds++;
}
@ -115,20 +114,20 @@ index 54c769f37f2331136c87a37c13fb4e3f9a8f22f9..ac52ab79a5fc3050effd2b1f2f605cee
}
@@ -931,6 +934,9 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
@@ -957,6 +960,9 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
}
else if (QUEUE_EMPTY(&w->watcher_queue))
QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
else if (uv__queue_empty(&w->watcher_queue))
uv__queue_insert_tail(&loop->watcher_queue, &w->watcher_queue);
+
+ if (uv__get_internal_fields(loop)->flags & UV_LOOP_INTERRUPT_ON_IO_CHANGE)
+ uv__loop_interrupt(loop);
}
@@ -947,6 +953,9 @@ void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
@@ -973,6 +979,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 (QUEUE_EMPTY(&w->pending_queue))
QUEUE_INSERT_TAIL(&loop->pending_queue, &w->pending_queue);
if (uv__queue_empty(&w->pending_queue))
uv__queue_insert_tail(&loop->pending_queue, &w->pending_queue);
+
+ if (uv__get_internal_fields(loop)->flags & UV_LOOP_INTERRUPT_ON_IO_CHANGE)
+ uv__loop_interrupt(loop);
@ -136,7 +135,7 @@ index 54c769f37f2331136c87a37c13fb4e3f9a8f22f9..ac52ab79a5fc3050effd2b1f2f605cee
diff --git a/deps/uv/src/unix/loop.c b/deps/uv/src/unix/loop.c
index a88e71c339351f2ebcdd6c3f933fc3b1122910ed..46fc03264b6cc1a3a4d8faf5ec5a754fc07c9b6d 100644
index a9468e8e19cbede795032980c47eb83aee1e0c68..2d28cf48efc3718de19b901b7e08b8a857d20740 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) {
@ -193,10 +192,10 @@ index a88e71c339351f2ebcdd6c3f933fc3b1122910ed..46fc03264b6cc1a3a4d8faf5ec5a754f
+ abort();
+}
diff --git a/deps/uv/src/uv-common.h b/deps/uv/src/uv-common.h
index 6001b0cf68d0b0268b578218b664a737f43c9521..5d2212571f4bcb648ab332f0c5650d0fdb37c03a 100644
index cd57e5a35153d0557351b60cce0c5be7a4468b60..660caef30b1637b8009de5e55ee34f48d17e4dd0 100644
--- a/deps/uv/src/uv-common.h
+++ b/deps/uv/src/uv-common.h
@@ -140,6 +140,8 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap);
@@ -144,6 +144,8 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap);
void uv__loop_close(uv_loop_t* loop);
@ -205,7 +204,7 @@ index 6001b0cf68d0b0268b578218b664a737f43c9521..5d2212571f4bcb648ab332f0c5650d0f
int uv__read_start(uv_stream_t* stream,
uv_alloc_cb alloc_cb,
uv_read_cb read_cb);
@@ -268,6 +270,10 @@ void uv__threadpool_cleanup(void);
@@ -280,6 +282,10 @@ void uv__threadpool_cleanup(void);
if (((h)->flags & UV_HANDLE_ACTIVE) != 0) break; \
(h)->flags |= UV_HANDLE_ACTIVE; \
if (((h)->flags & UV_HANDLE_REF) != 0) uv__active_handle_add(h); \
@ -217,7 +216,7 @@ index 6001b0cf68d0b0268b578218b664a737f43c9521..5d2212571f4bcb648ab332f0c5650d0f
while (0)
diff --git a/deps/uv/src/win/core.c b/deps/uv/src/win/core.c
index 67af93e6571ed4324d80b6dfb2ff93db7b9cd9b1..e88008b6a288d1508c5c117d814000d63cab81c3 100644
index e9885a0f1ff3890a8d957c8793e22b01cedc0e97..ae3d09878253fe7169ad7b74b3faea0223f89de5 100644
--- a/deps/uv/src/win/core.c
+++ b/deps/uv/src/win/core.c
@@ -384,10 +384,20 @@ int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) {
@ -242,7 +241,7 @@ index 67af93e6571ed4324d80b6dfb2ff93db7b9cd9b1..e88008b6a288d1508c5c117d814000d6
return -1;
}
diff --git a/deps/uv/test/test-embed.c b/deps/uv/test/test-embed.c
index 1d3355fdc67310feb63738c9e30724f0e77f7895..77a63dbb4d188b2ad571c814dbc6cbc6fe5fa205 100644
index bbe56e176db17a502d7f3864ba529212f553590a..b0da9d1cddc69428e9fb3379d1338cf893ab93d2 100644
--- a/deps/uv/test/test-embed.c
+++ b/deps/uv/test/test-embed.c
@@ -25,54 +25,184 @@
@ -463,13 +462,13 @@ index 1d3355fdc67310feb63738c9e30724f0e77f7895..77a63dbb4d188b2ad571c814dbc6cbc6
+ run_loop();
+ ASSERT_EQ(main_timer_called, 1);
MAKE_VALGRIND_HAPPY();
MAKE_VALGRIND_HAPPY(loop);
return 0;
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index b19c10c7e40c77061337416fd623c53d0863d276..1f54ac21c36902bccb35c64cefa8bb14dd675bb0 100644
index 78ff9c2d1621676feab5d357609970cdf1ba5864..204160f324ad1a80c9b042e62c4bedcb745666ba 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -265,6 +265,7 @@ TEST_DECLARE (process_priority)
@@ -273,6 +273,7 @@ TEST_DECLARE (process_priority)
TEST_DECLARE (has_ref)
TEST_DECLARE (active)
TEST_DECLARE (embed)
@ -477,7 +476,7 @@ index b19c10c7e40c77061337416fd623c53d0863d276..1f54ac21c36902bccb35c64cefa8bb14
TEST_DECLARE (async)
TEST_DECLARE (async_null_cb)
TEST_DECLARE (eintr_handling)
@@ -867,6 +868,7 @@ TASK_LIST_START
@@ -894,6 +895,7 @@ TASK_LIST_START
TEST_ENTRY (active)
TEST_ENTRY (embed)

Просмотреть файл

@ -6,10 +6,10 @@ Subject: feat: initialize asar support
This patch initializes asar support in Node.js.
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index b4a24bbffb6c43638d13063e85b6cfba5c0cc9c7..fcbd9ee1af002bc176937e6bb5af55791b2f64b2 100644
index 1f4a08515b5ae9e15ee987d9287f71b0fed3cb30..0dc769846b4e6fe84438cd6d8024c4a89eb90a9b 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -52,6 +52,8 @@ function prepareWorkerThreadExecution() {
@@ -67,6 +67,8 @@ function prepareWorkerThreadExecution() {
});
}
@ -18,7 +18,7 @@ index b4a24bbffb6c43638d13063e85b6cfba5c0cc9c7..fcbd9ee1af002bc176937e6bb5af5579
function prepareExecution(options) {
const { expandArgv1, initializeModules, isMainThread } = options;
@@ -130,12 +132,17 @@ function setupUserModules() {
@@ -170,12 +172,17 @@ function setupUserModules(isLoaderWorker = false) {
loadPreloadModules();
// Need to be done after --require setup.
initializeFrozenIntrinsics();

Просмотреть файл

@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 16 Nov 2023 16:48:10 +0100
Subject: feat: optionally prevent calling V8::EnableWebAssemblyTrapHandler
V8::EnableWebAssemblyTrapHandler can be called only once or it will
hard crash. We need to prevent Node.js calling it in the event it has
already been called.
This should be upstreamed.
diff --git a/src/node.cc b/src/node.cc
index 89e0e5524c2102b86bc5506fe49aa0c6fa0f30c1..e58f28e0f0ff8d61f35ec3c5a69aa37c66c25d78 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -605,6 +605,7 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
#endif
}
#endif // defined(_WIN32)
+ if (!(flags & ProcessInitializationFlags::kNoEnableWasmTrapHandler))
V8::EnableWebAssemblyTrapHandler(false);
#endif // NODE_USE_V8_WASM_TRAP_HANDLER
}
diff --git a/src/node.h b/src/node.h
index 9ac0d5addcdd40d5c91d375b626099b95729548a..3ffc51783b0b6dee1c0f0a37d2f52cb1aec2fa3f 100644
--- a/src/node.h
+++ b/src/node.h
@@ -272,6 +272,10 @@ enum Flags : uint32_t {
// cppgc::InitializeProcess() before creating a Node.js environment
// and call cppgc::ShutdownProcess() before process shutdown.
kNoInitializeCppgc = 1 << 13,
+ // Do not initialize the Web Assembly trap handler. This is used by
+ // embedders to account for the case where it may already have been
+ // initialized - calling it more than once will hard crash.
+ kNoEnableWasmTrapHandler = 1 << 14,
// Emulate the behavior of InitializeNodeWithArgs() when passing
// a flags argument to the InitializeOncePerProcess() replacement

Просмотреть файл

@ -28,10 +28,10 @@ In file included from ../../third_party/electron_node/src/env-inl.h:32:
1 error generated.
diff --git a/src/util.h b/src/util.h
index e218d9b62a1eb52404e3a57b999784e8e2f5ad58..22f2272c1bd4363be10a552748f63cbffba5c66d 100644
index 344f7753dab2b16bc38ff808d29c031a363aaaf2..947c2c19a22f7bf8a9d82667a85a18f9252e6d65 100644
--- a/src/util.h
+++ b/src/util.h
@@ -129,10 +129,10 @@ void DumpBacktrace(FILE* fp);
@@ -130,10 +130,10 @@ void DumpBacktrace(FILE* fp);
do { \
/* Make sure that this struct does not end up in inline code, but */ \
/* rather in a read-only data section when modifying this code. */ \

Просмотреть файл

@ -9,10 +9,10 @@ This patch can be removed when Node.js upgrades to a version of V8 with the abov
CL - they'll need to make the same change.
diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js
index a321f1b27adaa3f376f5e61ce5d9c1ceb3427cc7..85e8603023854de120219a98449ee64fb7372200 100644
index 59b83f531cf0a60f960d0096aea70854f45bd629..9dcc35987a4757ea090e81c7de38a6af5bc3182f 100644
--- a/test/parallel/test-fs-write.js
+++ b/test/parallel/test-fs-write.js
@@ -40,7 +40,7 @@ const constants = fs.constants;
@@ -38,7 +38,7 @@ const constants = fs.constants;
const { externalizeString, isOneByteString } = global;
// Account for extra globals exposed by --expose_externalize_string.

Просмотреть файл

@ -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 94fae0651890435348dacff2fe1838ea4db92037..10d11f1e9aacfbe4bb53e1220afab1e68db98313 100644
index d783c7f970237a648f585b9a9e5725494b5d9e2f..0b073571cd482d5124123c4490c564f839429b28 100644
--- a/common.gypi
+++ b/common.gypi
@@ -80,6 +80,23 @@

Просмотреть файл

@ -9,15 +9,13 @@ This patch can be removed when Node.js upgrades to a version of V8 that
includes this change.
diff --git a/test/parallel/test-v8-stats.js b/test/parallel/test-v8-stats.js
index 83b375bd3c5b5dbd5189d48ad560580883ac91f6..2366cbf716c11851bb3a759dce5db47d616516dc 100644
index dd774267910aa0920ed077dd5bd5cfed93aab6cb..2366cbf716c11851bb3a759dce5db47d616516dc 100644
--- a/test/parallel/test-v8-stats.js
+++ b/test/parallel/test-v8-stats.js
@@ -47,7 +47,9 @@ const expectedHeapSpaces = [
'old_space',
@@ -48,6 +48,8 @@ const expectedHeapSpaces = [
'read_only_space',
'shared_large_object_space',
- 'shared_space'
+ 'shared_space',
'shared_space',
+ 'trusted_large_object_space',
+ 'trusted_space'
];

Просмотреть файл

@ -13,15 +13,15 @@ if the override has been disabled.
This will be upstreamed.
diff --git a/lib/assert.js b/lib/assert.js
index 04c2dd3bfcfdfbb4b8079c306e1d80aa48027787..34658819d09cc20f372798caec79e19c4a36565d 100644
index b7d7a3da01d520984a5903cb9a0f1c288e0d5fa0..66a60c3726cd57e65db3e4fb57fb85721368c3ce 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -66,6 +66,7 @@ const { inspect } = require('internal/util/inspect');
const { isPromise, isRegExp } = require('internal/util/types');
const { EOL } = require('internal/constants');
const { BuiltinModule } = require('internal/bootstrap/loaders');
const { BuiltinModule } = require('internal/bootstrap/realm');
+const { getEmbedderOptions } = require('internal/options');
const { isError } = require('internal/util');
const { isError, deprecate } = require('internal/util');
const errorCache = new SafeMap();
@@ -293,8 +294,16 @@ function getErrMessage(message, fn) {
@ -44,10 +44,10 @@ index 04c2dd3bfcfdfbb4b8079c306e1d80aa48027787..34658819d09cc20f372798caec79e19c
const filename = call.getFileName();
const line = call.getLineNumber() - 1;
diff --git a/src/api/environment.cc b/src/api/environment.cc
index d5a03d5e10faaa204b3f9f290fed79be824c78b1..c4caef25af670658965fc740ce03c2d2c4ed3e66 100644
index c02906eacd90ac27d618e7578d1f928f16a858f7..74b4e15b8230c6380d41e84aa504824bb79b2ee5 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -263,6 +263,9 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
@@ -277,6 +277,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 d5a03d5e10faaa204b3f9f290fed79be824c78b1..c4caef25af670658965fc740ce03c2d2
}
diff --git a/src/node_options.cc b/src/node_options.cc
index 397f9d4a7a8e9a850ae2e13b84d7f893076f724d..365748f046f9d0f232d4f0ebc7b0c7f56bbd74e2 100644
index f711ac936e76f9c16d15d7db759d0081a9eb018d..6eb2c137e1dd05b05e781820905cf6778107275d 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -1215,6 +1215,11 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
@@ -1239,6 +1239,11 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
Local<Context> context = env->context();
Local<Object> ret = Object::New(isolate);

Просмотреть файл

@ -31,10 +31,10 @@ index 4e3c32fdcd23fbe3e74bd5e624b739d224689f33..19d65aae7fa8ec9f9b907733ead17a20
// Test Parallel Execution w/ KeyObject is threadsafe in openssl3
{
diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js
index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d9970d15c9a 100644
index 6178445adbc634160c3c3ca699a36868f894e544..ff4dc2f7d527b5eb1fa442ba6b0f9ba04af39357 100644
--- a/test/parallel/test-crypto-authenticated.js
+++ b/test/parallel/test-crypto-authenticated.js
@@ -50,7 +50,9 @@ const errMessages = {
@@ -48,7 +48,9 @@ const errMessages = {
const ciphers = crypto.getCiphers();
const expectedWarnings = common.hasFipsCrypto ?
@ -45,7 +45,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
['Use Cipheriv for counter mode of aes-192-gcm'],
['Use Cipheriv for counter mode of aes-192-ccm'],
['Use Cipheriv for counter mode of aes-192-ccm'],
@@ -318,7 +320,9 @@ for (const test of TEST_CASES) {
@@ -315,7 +317,9 @@ for (const test of TEST_CASES) {
// Test that create(De|C)ipher(iv)? throws if the mode is CCM and an invalid
// authentication tag length has been specified.
@ -56,7 +56,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
for (const authTagLength of [-1, true, false, NaN, 5.5]) {
assert.throws(() => {
crypto.createCipheriv('aes-256-ccm',
@@ -406,6 +410,10 @@ for (const test of TEST_CASES) {
@@ -403,6 +407,10 @@ for (const test of TEST_CASES) {
// authentication tag has been specified.
{
for (const mode of ['ccm', 'ocb']) {
@ -67,7 +67,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
assert.throws(() => {
crypto.createCipheriv(`aes-256-${mode}`,
'FxLKsqdmv0E9xrQhp0b1ZgI0K7JFZJM8',
@@ -440,7 +448,9 @@ for (const test of TEST_CASES) {
@@ -437,7 +445,9 @@ for (const test of TEST_CASES) {
}
// Test that setAAD throws if an invalid plaintext length has been specified.
@ -78,7 +78,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
const cipher = crypto.createCipheriv('aes-256-ccm',
'FxLKsqdmv0E9xrQhp0b1ZgI0K7JFZJM8',
'qkuZpJWCewa6S',
@@ -461,7 +471,9 @@ for (const test of TEST_CASES) {
@@ -458,7 +468,9 @@ for (const test of TEST_CASES) {
}
// Test that setAAD and update throw if the plaintext is too long.
@ -89,7 +89,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
for (const ivLength of [13, 12]) {
const maxMessageSize = (1 << (8 * (15 - ivLength))) - 1;
const key = 'FxLKsqdmv0E9xrQhp0b1ZgI0K7JFZJM8';
@@ -492,7 +504,9 @@ for (const test of TEST_CASES) {
@@ -489,7 +501,9 @@ for (const test of TEST_CASES) {
// Test that setAAD throws if the mode is CCM and the plaintext length has not
// been specified.
@ -100,7 +100,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
assert.throws(() => {
const cipher = crypto.createCipheriv('aes-256-ccm',
'FxLKsqdmv0E9xrQhp0b1ZgI0K7JFZJM8',
@@ -517,7 +531,9 @@ for (const test of TEST_CASES) {
@@ -514,7 +528,9 @@ for (const test of TEST_CASES) {
}
// Test that final() throws in CCM mode when no authentication tag is provided.
@ -111,7 +111,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
if (!common.hasFipsCrypto) {
const key = Buffer.from('1ed2233fa2223ef5d7df08546049406c', 'hex');
const iv = Buffer.from('7305220bca40d4c90e1791e9', 'hex');
@@ -549,7 +565,9 @@ for (const test of TEST_CASES) {
@@ -546,7 +562,9 @@ for (const test of TEST_CASES) {
}
// Test that an IV length of 11 does not overflow max_message_size_.
@ -122,7 +122,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
const key = 'x'.repeat(16);
const iv = Buffer.from('112233445566778899aabb', 'hex');
const options = { authTagLength: 8 };
@@ -566,6 +584,10 @@ for (const test of TEST_CASES) {
@@ -563,6 +581,10 @@ for (const test of TEST_CASES) {
const iv = Buffer.from('0123456789ab', 'utf8');
for (const mode of ['gcm', 'ocb']) {
@ -133,7 +133,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
for (const authTagLength of mode === 'gcm' ? [undefined, 8] : [8]) {
const cipher = crypto.createCipheriv(`aes-128-${mode}`, key, iv, {
authTagLength
@@ -600,6 +622,10 @@ for (const test of TEST_CASES) {
@@ -597,6 +619,10 @@ for (const test of TEST_CASES) {
const opts = { authTagLength: 8 };
for (const mode of ['gcm', 'ccm', 'ocb']) {
@ -144,7 +144,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
const cipher = crypto.createCipheriv(`aes-128-${mode}`, key, iv, opts);
const ciphertext = Buffer.concat([cipher.update(plain), cipher.final()]);
const tag = cipher.getAuthTag();
@@ -622,7 +648,9 @@ for (const test of TEST_CASES) {
@@ -619,7 +645,9 @@ for (const test of TEST_CASES) {
// Test chacha20-poly1305 rejects invalid IV lengths of 13, 14, 15, and 16 (a
// length of 17 or greater was already rejected).
// - https://www.openssl.org/news/secadv/20190306.txt
@ -155,7 +155,7 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
// Valid extracted from TEST_CASES, check that it detects IV tampering.
const valid = {
algo: 'chacha20-poly1305',
@@ -667,6 +695,9 @@ for (const test of TEST_CASES) {
@@ -664,6 +692,9 @@ for (const test of TEST_CASES) {
{
// CCM cipher without data should not crash, see https://github.com/nodejs/node/issues/38035.
@ -165,92 +165,6 @@ index d358f6b63c0e9f5761157dc200daa484d9c5ead6..7a3e376d04020e7a883f56591bc07d99
const algo = 'aes-128-ccm';
const key = Buffer.alloc(16);
const iv = Buffer.alloc(12);
diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js
index 3bbca5b0da395b94c04da7bb7c55b107e41367d8..af62558c4f23aa82804e0077da7b7f3a86cfac60 100644
--- a/test/parallel/test-crypto-binary-default.js
+++ b/test/parallel/test-crypto-binary-default.js
@@ -51,15 +51,15 @@ tls.createSecureContext({ pfx: certPfx, passphrase: 'sample' });
assert.throws(function() {
tls.createSecureContext({ pfx: certPfx });
-}, /^Error: mac verify failure$/);
+}, /^Error: (mac verify failure|INCORRECT_PASSWORD)$/);
assert.throws(function() {
tls.createSecureContext({ pfx: certPfx, passphrase: 'test' });
-}, /^Error: mac verify failure$/);
+}, /^Error: (mac verify failure|INCORRECT_PASSWORD)$/);
assert.throws(function() {
tls.createSecureContext({ pfx: 'sample', passphrase: 'test' });
-}, /^Error: not enough data$/);
+}, /^Error: (not enough data|BAD_PKCS12_DATA)$/);
// Test HMAC
{
@@ -462,7 +462,7 @@ assert.throws(function() {
function testCipher1(key) {
// Test encryption and decryption
const plaintext = 'Keep this a secret? No! Tell everyone about node.js!';
- const cipher = crypto.createCipher('aes192', key);
+ const cipher = crypto.createCipher('aes-192-cbc', key);
// Encrypt plaintext which is in utf8 format
// to a ciphertext which will be in hex
@@ -470,7 +470,7 @@ function testCipher1(key) {
// Only use binary or hex, not base64.
ciph += cipher.final('hex');
- const decipher = crypto.createDecipher('aes192', key);
+ const decipher = crypto.createDecipher('aes-192-cbc', key);
let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');
@@ -485,14 +485,14 @@ function testCipher2(key) {
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
'jAfaFg**';
- const cipher = crypto.createCipher('aes256', key);
+ const cipher = crypto.createCipher('aes-256-cbc', key);
// Encrypt plaintext which is in utf8 format
// to a ciphertext which will be in Base64
let ciph = cipher.update(plaintext, 'utf8', 'base64');
ciph += cipher.final('base64');
- const decipher = crypto.createDecipher('aes256', key);
+ const decipher = crypto.createDecipher('aes-256-cbc', key);
let txt = decipher.update(ciph, 'base64', 'utf8');
txt += decipher.final('utf8');
@@ -537,6 +537,10 @@ function testCipher4(key, iv) {
function testCipher5(key, iv) {
+ if (!crypto.getCiphers().includes('id-aes128-wrap')) {
+ common.printSkipMessage(`unsupported id-aes128-wrap test`);
+ return;
+ }
// Test encryption and decryption with explicit key with aes128-wrap
const plaintext =
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
@@ -662,6 +666,8 @@ assert.throws(
}
+/* NB: BoringSSL does not support using DSA through the EVP API.
+ * https://boringssl.googlesource.com/boringssl/+/a2278d4d2cabe73f6663e3299ea7808edfa306b9/PORTING.md#dsa-s
//
// Test DSA signing and verification
//
@@ -682,6 +688,7 @@ assert.throws(
assert.strictEqual(verify.verify(publicKey, signature, 'hex'), true);
}
+*/
//
diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js
index 4a5f1f149fe6c739f7f1d2ee17df6e61a942d621..b3287f428ce6b3fde11d449c601a57ff5e3843f9 100644
--- a/test/parallel/test-crypto-certificate.js
@ -432,11 +346,11 @@ index 81a469c226c261564dee1e0b06b6571b18a41f1f..58b66045dba4201b7ebedd78b129420f
assert.notStrictEqual(bad_dh.verifyError, 0);
const availableCurves = new Set(crypto.getCurves());
diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
index c730eac4ce76dde880fe2b36b17414b0c311ac0b..416cfa0ac019fe5eab696df36f6cc65e311bf20f 100644
--- a/test/parallel/test-crypto-dh.js
+++ b/test/parallel/test-crypto-dh.js
@@ -47,17 +47,19 @@ for (const bits of [-1, 0, 1]) {
diff --git a/test/parallel/test-crypto-dh-errors.js b/test/parallel/test-crypto-dh-errors.js
index fcf1922bcdba733af6c22f142db4f7b099947757..9f72ae4e41a113e752f40795103c2af514538780 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]) {
});
} else {
assert.throws(() => crypto.createDiffieHellman(bits), {
@ -448,8 +362,57 @@ index c730eac4ce76dde880fe2b36b17414b0c311ac0b..416cfa0ac019fe5eab696df36f6cc65e
});
}
}
@@ -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 abbe1abe7e53d7bd113afb68b0e9af1e814c70bd..086a8e38021ed1a87be22246cdb4f5ceb56eee4c 100644
--- a/test/parallel/test-crypto-dh.js
+++ b/test/parallel/test-crypto-dh.js
@@ -55,18 +55,17 @@ const crypto = require('crypto');
let wrongBlockLength;
if (common.hasOpenSSL3) {
wrongBlockLength = {
- message: 'error:1C80006B:Provider routines::wrong final block length',
- code: 'ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH',
- library: 'Provider routines',
- reason: 'wrong final block length'
+ message: /error:1C80006B:Provider routines::wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
+ code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
+ library: /digital envelope routines|Cipher functions/,
+ reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
};
} else {
wrongBlockLength = {
- message: 'error:0606506D:digital envelope' +
- ' routines:EVP_DecryptFinal_ex:wrong final block length',
- code: 'ERR_OSSL_EVP_WRONG_FINAL_BLOCK_LENGTH',
- library: 'digital envelope routines',
- reason: 'wrong final block length'
+ message: /error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
+ code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
+ library: /digital envelope routines|Cipher functions/,
+ reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
};
}
-// Through a fluke of history, g=0 defaults to DH_GENERATOR (2).
@@ -95,10 +94,16 @@ const crypto = require('crypto');
// Through a fluke of history, g=0 defaults to DH_GENERATOR (2).
{
const g = 0;
- crypto.createDiffieHellman('abcdef', g);
@ -460,63 +423,13 @@ index c730eac4ce76dde880fe2b36b17414b0c311ac0b..416cfa0ac019fe5eab696df36f6cc65e
crypto.createDiffieHellman('abcdef', 'hex', g);
}
@@ -65,13 +67,18 @@ 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);
}
-crypto.createDiffieHellman('abcdef', Buffer.from([2])); // OK
+{
{
- crypto.createDiffieHellman('abcdef', Buffer.from([2])); // OK
+ assert.throws(() => crypto.createDiffieHellman('abcdef', Buffer.from([2])), {
+ code: /INVALID_PARAMETERS/,
+ name: 'Error'
+ });
+}
for (const g of [Buffer.from([]),
Buffer.from([0]),
@@ -79,7 +86,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);
@@ -133,18 +140,17 @@ assert.strictEqual(secret1, secret4);
let wrongBlockLength;
if (common.hasOpenSSL3) {
wrongBlockLength = {
- message: 'error:1C80006B:Provider routines::wrong final block length',
- code: 'ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH',
- library: 'Provider routines',
- reason: 'wrong final block length'
+ message: /error:1C80006B:Provider routines::wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
+ code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
+ library: /digital envelope routines|Cipher functions/,
+ reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
};
} else {
wrongBlockLength = {
- message: 'error:0606506D:digital envelope' +
- ' routines:EVP_DecryptFinal_ex:wrong final block length',
- code: 'ERR_OSSL_EVP_WRONG_FINAL_BLOCK_LENGTH',
- library: 'digital envelope routines',
- reason: 'wrong final block length'
+ message: /error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length|error:1e00007b:Cipher functions:OPENSSL_internal:WRONG_FINAL_BLOCK_LENGTH/,
+ code: /ERR_OSSL_(EVP_)?WRONG_FINAL_BLOCK_LENGTH/,
+ library: /digital envelope routines|Cipher functions/,
+ reason: /wrong final block length|WRONG_FINAL_BLOCK_LENGTH/
};
}
diff --git a/test/parallel/test-crypto-getcipherinfo.js b/test/parallel/test-crypto-getcipherinfo.js
index 98d2a52eceac4bc564fd2878f77b50c336a67a66..bcb2de6e354c26816000f2400d9c1d46de01888a 100644
--- a/test/parallel/test-crypto-getcipherinfo.js
@ -672,10 +585,10 @@ index 9afcb38616dafd6da1ab7b5843d68f4f796ca9a6..00d3381056a5a40c549f06d74c130149
}
+*/
diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js
index 74c0ff53eb18b749d4018b50d654df943403245b..aab253ca5d4504c445c88cd9519f8385a7b39b91 100644
index b39ec22dceb5b704f8c262bd38163d93ac1a3b47..89cfa9fc49719e5a6f2c5b96f25c61340286cadb 100644
--- a/test/parallel/test-crypto-sign-verify.js
+++ b/test/parallel/test-crypto-sign-verify.js
@@ -29,6 +29,7 @@ const keySize = 2048;
@@ -28,6 +28,7 @@ const keySize = 2048;
'instance when called without `new`');
}
@ -683,7 +596,7 @@ index 74c0ff53eb18b749d4018b50d654df943403245b..aab253ca5d4504c445c88cd9519f8385
// Test handling of exceptional conditions
{
const library = {
@@ -69,6 +70,7 @@ const keySize = 2048;
@@ -68,6 +69,7 @@ const keySize = 2048;
delete Object.prototype.opensslErrorStack;
}
@ -691,7 +604,7 @@ index 74c0ff53eb18b749d4018b50d654df943403245b..aab253ca5d4504c445c88cd9519f8385
assert.throws(
() => crypto.createVerify('SHA256').verify({
@@ -342,15 +344,17 @@ assert.throws(
@@ -341,15 +343,17 @@ assert.throws(
padding: crypto.constants.RSA_PKCS1_OAEP_PADDING
});
}, common.hasOpenSSL3 ? {
@ -713,7 +626,7 @@ index 74c0ff53eb18b749d4018b50d654df943403245b..aab253ca5d4504c445c88cd9519f8385
});
}
@@ -420,10 +424,12 @@ assert.throws(
@@ -419,10 +423,12 @@ assert.throws(
public: fixtures.readKey('ed25519_public.pem', 'ascii'),
algo: null,
sigLen: 64 },
@ -726,7 +639,7 @@ index 74c0ff53eb18b749d4018b50d654df943403245b..aab253ca5d4504c445c88cd9519f8385
{ private: fixtures.readKey('rsa_private_2048.pem', 'ascii'),
public: fixtures.readKey('rsa_public_2048.pem', 'ascii'),
algo: 'sha1',
@@ -494,7 +500,7 @@ assert.throws(
@@ -493,7 +499,7 @@ assert.throws(
{
const data = Buffer.from('Hello world');
@ -755,7 +668,7 @@ 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 930a2ba09088663298208f165f06a7710770938f..592b4140f14e659dfa38e438473c8d4ac4ae60ab 100644
index 89a7521544f7051edc1779138551bbad1972b3fb..91df6acc65d4003999f29f0fa5f639056b21ee3b 100644
--- a/test/parallel/test-crypto-x509.js
+++ b/test/parallel/test-crypto-x509.js
@@ -111,7 +111,7 @@ const der = Buffer.from(
@ -783,8 +696,8 @@ index 930a2ba09088663298208f165f06a7710770938f..592b4140f14e659dfa38e438473c8d4a
+
// Verify that legacy encoding works
const legacyObjectCheck = {
subject: Object.assign(Object.create(null), {
@@ -277,16 +287,8 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI=
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']
}),
@ -797,11 +710,10 @@ index 930a2ba09088663298208f165f06a7710770938f..592b4140f14e659dfa38e438473c8d4a
- 'C574197693E959CEA1362FFAE1BBA10C8C0D88840ABFEF103631B2E8F5C3' +
- '9B5548A7EA57E8A39F89291813F45A76C448033A2B7ED8403F4BAA147CF3' +
- '5E2D2554AA65CE49695797095BF4DC6B',
bits: 2048,
+ modulusPattern: new RegExp(modulusOSSL, 'i'),
bits: 2048,
exponent: '0x10001',
valid_from: 'Sep 3 21:40:37 2022 GMT',
valid_to: 'Jun 17 21:40:37 2296 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:' +
@ -953,7 +865,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 940c43cc40bf15e51df177ee30ecc69ffbeec296..e95743a91a3c709c7d2c10dc80b3f75b7d988027 100644
index da5600710560b22049eba1ef18bbb742d447a673..8917b96f666de916616af2fb3ce3a58d00af7438 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 = {
@ -993,10 +905,10 @@ index aa685ca9e09cf0d17ff4d5480089e9977dd51f72..ccafa427433922155c1afd5d95ba69d8
}));
socket.end('Hello');
diff --git a/test/parallel/test-tls-getprotocol.js b/test/parallel/test-tls-getprotocol.js
index d45287d671d8afb1be391d391efc4d098d0b77c9..86f1a12528b535eefeb8c263581f1240f3df5771 100644
index 7da2f60676d00e8e40d890f2efd46102154ca34d..2230b8cf85259d6670e274d6b84d83fd8788e83e 100644
--- a/test/parallel/test-tls-getprotocol.js
+++ b/test/parallel/test-tls-getprotocol.js
@@ -18,7 +18,7 @@ const clientConfigs = [
@@ -27,7 +27,7 @@ const clientConfigs = [
const serverConfig = {
secureProtocol: 'TLS_method',
@ -1019,10 +931,10 @@ 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 442423954b10b2ee1696eb7db56eaa4c88492122..cbb96d7de046c80fad608431b7ec0216e2d271fb 100644
index eb09bc24f0cb8244b05987e3a7c1d203360d3a38..da891fffa29d5666d91e4445e54c43e3688b870a 100644
--- a/test/parallel/test-webcrypto-derivebits.js
+++ b/test/parallel/test-webcrypto-derivebits.js
@@ -101,6 +101,7 @@ const { subtle } = require('crypto').webcrypto;
@@ -101,6 +101,7 @@ const { subtle } = globalThis.crypto;
tests.then(common.mustCall());
}
@ -1030,16 +942,16 @@ index 442423954b10b2ee1696eb7db56eaa4c88492122..cbb96d7de046c80fad608431b7ec0216
// Test X25519 and X448 bit derivation
{
async function test(name) {
@@ -126,3 +127,4 @@ const { subtle } = require('crypto').webcrypto;
@@ -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 b819b998d217e0c71e9b41f175de6802d3ac7d90..fbd32b02abd120aa02b9ac92341ef1331422308d 100644
index 558d37d90d5796b30101d1b512c9df3e7661d0db..c18f9670b10cb84c6902391f20e0ff75729cc960 100644
--- a/test/parallel/test-webcrypto-derivekey.js
+++ b/test/parallel/test-webcrypto-derivekey.js
@@ -174,6 +174,7 @@ const { webcrypto: { subtle }, KeyObject } = require('crypto');
@@ -175,6 +175,7 @@ const { KeyObject } = require('crypto');
})().then(common.mustCall());
}
@ -1047,16 +959,16 @@ index b819b998d217e0c71e9b41f175de6802d3ac7d90..fbd32b02abd120aa02b9ac92341ef133
// Test X25519 and X448 key derivation
{
async function test(name) {
@@ -208,3 +209,4 @@ const { webcrypto: { subtle }, KeyObject } = require('crypto');
@@ -209,3 +210,4 @@ const { KeyObject } = require('crypto');
test('X25519').then(common.mustCall());
test('X448').then(common.mustCall());
}
+*/
diff --git a/test/parallel/test-webcrypto-sign-verify.js b/test/parallel/test-webcrypto-sign-verify.js
index 6c6b15781549a4b37781bf0b8014054dc5d8c746..142d41b169c836201660d78c19383f3ffc469407 100644
index de736102bdcb71a5560c95f7041537f25026aed4..638fdf0d798f3309528c63f0f8598f3df5528339 100644
--- a/test/parallel/test-webcrypto-sign-verify.js
+++ b/test/parallel/test-webcrypto-sign-verify.js
@@ -105,6 +105,7 @@ const { subtle } = require('crypto').webcrypto;
@@ -105,6 +105,7 @@ const { subtle } = globalThis.crypto;
test('hello world').then(common.mustCall());
}
@ -1064,13 +976,13 @@ index 6c6b15781549a4b37781bf0b8014054dc5d8c746..142d41b169c836201660d78c19383f3f
// Test Sign/Verify Ed25519
{
async function test(data) {
@@ -144,3 +145,4 @@ const { subtle } = require('crypto').webcrypto;
@@ -144,3 +145,4 @@ const { subtle } = globalThis.crypto;
test('hello world').then(common.mustCall());
}
+*/
diff --git a/test/parallel/test-webcrypto-wrap-unwrap.js b/test/parallel/test-webcrypto-wrap-unwrap.js
index 670f19b7e4a190a222cc997f67975c3d49f65035..d4c4812cab56bcb51435aa6dd27545368fc11ed7 100644
index d1ca571af4be713082d32093bfb8a65f2aef9800..57b8df2ce18df58ff54b2d828af67e3c2e082fe0 100644
--- a/test/parallel/test-webcrypto-wrap-unwrap.js
+++ b/test/parallel/test-webcrypto-wrap-unwrap.js
@@ -18,14 +18,15 @@ const kWrappingData = {
@ -1102,7 +1014,7 @@ index 670f19b7e4a190a222cc997f67975c3d49f65035..d4c4812cab56bcb51435aa6dd2754536
function generateWrappingKeys() {
diff --git a/test/parallel/test-x509-escaping.js b/test/parallel/test-x509-escaping.js
index 170103fd9c973d64a30ee319a45c7e11c72a19d4..c19118146269651e4fe7d5591360876ce66bb1f6 100644
index e6ae4d886908cbc0e56787009db855dad8b12ba7..a17147daa0576ec49e560c05448f1ed0ae8d5640 100644
--- a/test/parallel/test-x509-escaping.js
+++ b/test/parallel/test-x509-escaping.js
@@ -447,7 +447,7 @@ const { hasOpenSSL3 } = common;

Просмотреть файл

@ -5,20 +5,32 @@ 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/translators.js b/lib/internal/modules/esm/translators.js
index 4c3a0d8c484a402fe419a0bd45c7e2b1d717cb4a..b8be4cde3bbe4b14e607a2bef0a2405df3cae533 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -309,6 +309,8 @@ function cjsPreparseModuleExports(filename, source) {
const cached = cjsParseCache.get(module);
if (cached)
return { module, exportNames: cached.exportNames };
+ if (filename === 'electron')
+ return { module };
}
const loaded = Boolean(module);
if (!loaded) {
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
index daaa153516c424334c18b5dfa35e0e55e1fbcce4..6181cc21bf303c41ed9c65681a34f6393223fb67 100644
index 0bfe7b11241416bfca0d470047b14777ad99307f..c86add4395ed59cee0d880961e7572b0cc3d6698 100644
--- a/lib/internal/modules/run_main.js
+++ b/lib/internal/modules/run_main.js
@@ -3,6 +3,7 @@
@@ -2,12 +2,19 @@
const {
ObjectCreate,
StringPrototypeEndsWith,
+ StringPrototypeStartsWith,
} = primordials;
const CJSLoader = require('internal/modules/cjs/loader');
const { Module, toRealPath, readPackageScope } = CJSLoader;
@@ -13,6 +14,13 @@ const {
} = require('internal/modules/esm/handle_process_exit');
const { getOptionValue } = require('internal/options');
const path = require('path');
function resolveMainPath(main) {
+ // For built-in modules used as the main entry point we _never_
@ -27,11 +39,10 @@ index daaa153516c424334c18b5dfa35e0e55e1fbcce4..6181cc21bf303c41ed9c65681a34f639
+ if (typeof main === 'string' && StringPrototypeStartsWith(main, 'electron/js2c')) {
+ return main;
+ }
+
// Note extension resolution for the main entry point can be deprecated in a
// future major.
// Module._findPath is monkey-patchable here.
@@ -28,6 +36,13 @@ function resolveMainPath(main) {
@@ -24,6 +31,12 @@ function resolveMainPath(main) {
}
function shouldUseESMLoader(mainPath) {
@ -41,7 +52,6 @@ index daaa153516c424334c18b5dfa35e0e55e1fbcce4..6181cc21bf303c41ed9c65681a34f639
+ if (typeof mainPath === 'string' && StringPrototypeStartsWith(mainPath, 'electron/js2c')) {
+ return false;
+ }
+
/**
* @type {string[]} userLoaders A list of custom loaders registered by the user
* (or an empty list when none have been registered).

Просмотреть файл

@ -10,45 +10,50 @@ parameters.
This should be upstreamed.
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 4d4b59916bfdb203702c4e878ff2659b79de8c52..6451464c9fb411a1988bada86eabb4071ee07eb0 100644
index f3cda64beaa1403cb33f1b0bd8089f3dfcbfc8b9..77386bd234d0b49b122f1de3d27b1a92da5d0ea4 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -435,6 +435,22 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
return maybe;
@@ -482,6 +482,18 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
return fn->Call(context, undefined, argc, argv);
}
+MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
+ Local<Context> context,
+ const char* id,
+ std::vector<Local<String>>* parameters,
+ Environment* optional_env) {
+ Result result;
+ Realm* optional_realm) {
+ Isolate* isolate = context->GetIsolate();
+
+ MaybeLocal<Function> maybe = GetInstance()->LookupAndCompileInternal(
+ context, id, parameters, &result);
+ if (optional_env != nullptr) {
+ RecordResult(id, result, optional_env);
+ }
+ MaybeLocal<Function> maybe = LookupAndCompileInternal(
+ context, id, parameters, optional_realm);
+ return maybe;
+}
+
bool BuiltinLoader::CompileAllBuiltins(Local<Context> context) {
BuiltinLoader* loader = GetInstance();
std::vector<std::string> ids = loader->GetBuiltinIds();
std::vector<std::string_view> ids = GetBuiltinIds();
bool all_succeeded = true;
diff --git a/src/node_builtins.h b/src/node_builtins.h
index 8d9f7c409659a30747e5feeac6cfec4208791370..34a51c3e5a79154c3633143b352aa9e108497767 100644
index 11d10f52b7c492bfae4bc58b39c20a693762a72d..b995e15fcd795f310126a38ec652efcd9fd36945 100644
--- a/src/node_builtins.h
+++ b/src/node_builtins.h
@@ -50,6 +50,11 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
v8::Local<v8::Context> context,
const char* id,
Environment* optional_env);
+ static v8::MaybeLocal<v8::Function> LookupAndCompile(
@@ -99,6 +99,12 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
const char* id,
Realm* optional_realm);
+ v8::MaybeLocal<v8::Function> LookupAndCompile(
+ v8::Local<v8::Context> context,
+ const char* id,
+ std::vector<v8::Local<v8::String>>* parameters,
+ Environment* optional_env);
+ Realm* optional_realm);
+
v8::MaybeLocal<v8::Value> CompileAndCall(v8::Local<v8::Context> context,
const char* id,
int argc,
@@ -109,6 +115,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
const char* id,
Realm* realm);
static v8::Local<v8::Object> GetSourceObject(v8::Local<v8::Context> context);
+
// Returns config.gypi as a JSON string
v8::Local<v8::String> GetConfigString(v8::Isolate* isolate);
bool Exists(const char* id);

Просмотреть файл

@ -6,22 +6,32 @@ 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 219ef03a21214deb8961044cfc18ef9c1e711b60..7749b37001f869fe565d8c450ff7ca2b6f3faa7a 100644
index 4ac9c011d153f4cb39cb7d4f46de0f8e65f70a56..f8462b69368aa7987e1e8ac8cd73e4ff2d921c51 100644
--- a/lib/internal/modules/esm/get_format.js
+++ b/lib/internal/modules/esm/get_format.js
@@ -30,6 +30,7 @@ const protocolHandlers = {
@@ -27,6 +27,7 @@ const protocolHandlers = {
'http:': getHttpProtocolModuleFormat,
'https:': getHttpProtocolModuleFormat,
'node:'() { return 'builtin'; },
+ 'electron:'() { return 'commonjs'; },
+ 'electron:'() { return 'electron'; },
};
/**
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index 71a9f8da0b49f3dca786eab07d44201a1bc76240..d8a072cf6af3b0d3a47ee69be04b26875683d261 100644
index d064296d11c463616111d28a32b7ad3f6a72bebd..14d5236d0ead946acf9a2f63bf979e7193bfbf56 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -121,6 +121,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
@@ -123,7 +123,8 @@ async function defaultLoad(url, context = kEmptyObject) {
if (
format === 'builtin' ||
- format === 'commonjs'
+ format === 'commonjs' ||
+ format === 'electron'
) {
source = null;
} else if (source == null) {
@@ -201,6 +202,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
protocol !== 'file:' &&
protocol !== 'data:' &&
protocol !== 'node:' &&
@ -29,7 +39,7 @@ index 71a9f8da0b49f3dca786eab07d44201a1bc76240..d8a072cf6af3b0d3a47ee69be04b2687
(
!experimentalNetworkImports ||
(
@@ -129,7 +130,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
@@ -209,7 +211,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
)
)
) {
@ -39,22 +49,23 @@ index 71a9f8da0b49f3dca786eab07d44201a1bc76240..d8a072cf6af3b0d3a47ee69be04b2687
ArrayPrototypePush(schemes, 'https', 'http');
}
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
index 7006887a6fe2bab525e52c6b0c76b5d089699a14..a93d93b3c2aae3ef790ffa4f417d50b884451549 100644
index acb5ddca8af3d2495ce27d6426b28e6ff73a8f33..acfcc1f1f92548117ded857fa8d4dd140e07ab2b 100644
--- a/lib/internal/modules/esm/resolve.js
+++ b/lib/internal/modules/esm/resolve.js
@@ -825,6 +825,8 @@ function parsePackageName(specifier, base) {
@@ -725,6 +725,8 @@ function parsePackageName(specifier, base) {
return { packageName, packageSubpath, isScoped };
}
+const electronSpecifiers = new SafeSet(['electron', 'electron/main', 'electron/common', 'electron/renderer']);
+const electronTypes = ['electron', 'electron/main', 'electron/common', 'electron/renderer'];
+
/**
* @param {string} specifier
* @param {string | URL | undefined} base
@@ -837,6 +839,10 @@ function packageResolve(specifier, base, conditions) {
@@ -736,6 +738,11 @@ function packageResolve(specifier, base, conditions) {
return new URL('node:' + specifier);
}
+ const electronSpecifiers = new SafeSet(electronTypes);
+ if (electronSpecifiers.has(specifier)) {
+ return new URL('electron:electron');
+ }
@ -63,22 +74,22 @@ index 7006887a6fe2bab525e52c6b0c76b5d089699a14..a93d93b3c2aae3ef790ffa4f417d50b8
parsePackageName(specifier, base);
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index a425749e82acd7593c9fb1ceffedc119a4e416f2..1ceb89da21610c703f4a18be5888373c7feaa370 100644
index b143cd0ad34d0e039db3e7493be00d923cc68b2d..178f362b2869173d51b2e97a8d35a16ab4ed4962 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -154,7 +154,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
@@ -220,7 +220,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
if (!cjsParse) await initCJSParse();
const { module, exportNames } = cjsPreparseModuleExports(filename);
const { exportNames, module } = cjsPreparseModuleExports(filename, source);
cjsCache.set(url, module);
- const namesWithDefault = exportNames.has('default') ?
+ const namesWithDefault = filename === 'electron' ? ['default', ...Object.keys(module.exports)] : exportNames.has('default') ?
[...exportNames] : ['default', ...exportNames];
return new ModuleWrap(url, undefined, namesWithDefault, function() {
@@ -173,9 +173,9 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
}
if (isMain) {
@@ -241,9 +241,9 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
} else {
({ exports } = module);
}
- for (const exportName of exportNames) {
- if (!ObjectPrototypeHasOwnProperty(exports, exportName) ||
- exportName === 'default')
@ -88,11 +99,22 @@ index a425749e82acd7593c9fb1ceffedc119a4e416f2..1ceb89da21610c703f4a18be5888373c
continue;
// We might trigger a getter -> dont fail.
let value;
@@ -267,6 +267,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
return createCJSModuleWrap(url, source);
});
+translators.set('electron', () => {
+ return createCJSModuleWrap('electron', '');
+});
+
// Handle CommonJS modules referenced by `import` statements or expressions,
// or as the initial entry point when the ESM loader handles a CommonJS entry.
translators.set('commonjs', async function commonjsStrategy(url, source,
diff --git a/lib/internal/url.js b/lib/internal/url.js
index 9c11377aef1f24c6ce5cfdf02b800440afc4686a..b66a5bbde3e8c419d5385339805cbd94f630986d 100644
index 8d5926e8fcb9df031e37698588075a34a80aea6c..6df0b68c8d35445d5f02475678484a6d5157762e 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -1432,6 +1432,8 @@ function fileURLToPath(path) {
@@ -1389,6 +1389,8 @@ function fileURLToPath(path) {
path = new URL(path);
else if (!isURL(path))
throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path);

Просмотреть файл

@ -7,10 +7,10 @@ Subject: fix: expose tracing::Agent and use tracing::TracingController instead
This API is used by Electron to create Node's tracing controller.
diff --git a/src/api/environment.cc b/src/api/environment.cc
index e1095037f3b9970e3ffd314b641b454f1248e33e..7ef6d04794c31064c70dbbb0bfc1dd7bf4d1b8fc 100644
index 6a6164b6d294430b6f2fe826cdcef5a9cc3f9660..035f495687856b0cfbcc4e87ba6e90d56c99e837 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -520,6 +520,10 @@ MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) {
@@ -583,6 +583,10 @@ MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env) {
return env->platform();
}
@ -22,10 +22,10 @@ index e1095037f3b9970e3ffd314b641b454f1248e33e..7ef6d04794c31064c70dbbb0bfc1dd7b
int thread_pool_size,
node::tracing::TracingController* tracing_controller) {
diff --git a/src/node.h b/src/node.h
index ac9bce58f33380cd8b687a088176a446c1e8cf34..b50bd5a941d381778d464fdb2770566a3ac34fed 100644
index ca01c42e8af484def476ba27cb270a0cc90226c9..dcce529664e1d126115545d6ba7f5b8492b0e921 100644
--- a/src/node.h
+++ b/src/node.h
@@ -130,6 +130,7 @@ namespace node {
@@ -132,6 +132,7 @@ struct SnapshotData;
namespace tracing {
@ -33,7 +33,7 @@ index ac9bce58f33380cd8b687a088176a446c1e8cf34..b50bd5a941d381778d464fdb2770566a
class TracingController;
}
@@ -688,6 +689,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
@@ -772,6 +773,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);

Просмотреть файл

@ -17,7 +17,7 @@ Upstreams:
- https://github.com/nodejs/node/pull/39136
diff --git a/src/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc
index 2685f5ea0bea998094453a5a29d23b1aaae55667..0ad4ba47b50a87bcf9e31a73c20a3a51be4ab96e 100644
index 2e6e02d229b67bc97e0d15a2704e091d5289df9c..6fd0416820998bd0ba4c4cd4fe3093f144610f18 100644
--- a/src/crypto/crypto_cipher.cc
+++ b/src/crypto/crypto_cipher.cc
@@ -27,7 +27,8 @@ using v8::Value;
@ -104,7 +104,7 @@ index c6120a655ec853aef11c66ed37d7ca0ffb957dd3..a52ca15cb0ab592d4196d4bd0f113324
if (!Set(env->context(),
obj,
diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc
index 838ee2a68dffc5a2aeca2bdb51b076795b2b145f..b0b18cd30c854c8c30d74afbf3ed352d3d23f30d 100644
index 3876adf7d72211d8d8c5a94564168094ecfc660b..ccd166d9439a821328d2ad35352488960206f65e 100644
--- a/src/crypto/crypto_context.cc
+++ b/src/crypto/crypto_context.cc
@@ -63,7 +63,7 @@ inline X509_STORE* GetOrCreateRootCertStore() {
@ -116,7 +116,7 @@ index 838ee2a68dffc5a2aeca2bdb51b076795b2b145f..b0b18cd30c854c8c30d74afbf3ed352d
if (!bio) return nullptr;
ByteSource bsrc = ByteSource::FromStringOrBuffer(env, v);
if (bsrc.size() > INT_MAX) return nullptr;
@@ -855,10 +855,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
@@ -861,10 +861,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
// If the user specified "auto" for dhparams, the JavaScript layer will pass
// true to this function instead of the original string. Any other string
// value will be interpreted as custom DH parameters below.
@ -130,10 +130,10 @@ index 838ee2a68dffc5a2aeca2bdb51b076795b2b145f..b0b18cd30c854c8c30d74afbf3ed352d
DHPointer dh;
{
diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc
index dd69323b80076d7333b80453c9cc9ef5b680ce27..6431b768c83fa27b2287588e936f93ae00169ad5 100644
index 408d6be2a9cfdbcb52af285204c07c40bf74a5a9..9c3244a14bc286d60805bac5719df6595d802768 100644
--- a/src/crypto/crypto_dh.cc
+++ b/src/crypto/crypto_dh.cc
@@ -154,13 +154,11 @@ bool DiffieHellman::Init(BignumPointer&& bn_p, int g) {
@@ -153,13 +153,11 @@ bool DiffieHellman::Init(BignumPointer&& bn_p, int g) {
bool DiffieHellman::Init(const char* p, int p_len, int g) {
dh_.reset(DH_new());
if (p_len <= 0) {
@ -149,7 +149,7 @@ index dd69323b80076d7333b80453c9cc9ef5b680ce27..6431b768c83fa27b2287588e936f93ae
return false;
}
BIGNUM* bn_p =
@@ -178,21 +176,18 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) {
@@ -177,21 +175,18 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) {
bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) {
dh_.reset(DH_new());
if (p_len <= 0) {
@ -174,7 +174,7 @@ index dd69323b80076d7333b80453c9cc9ef5b680ce27..6431b768c83fa27b2287588e936f93ae
return false;
}
BIGNUM* bn_p =
@@ -219,8 +214,10 @@ typedef BignumPointer (*StandardizedGroupInstantiator)();
@@ -218,8 +213,10 @@ typedef BignumPointer (*StandardizedGroupInstantiator)();
inline StandardizedGroupInstantiator FindDiffieHellmanGroup(const char* name) {
#define V(n, p) \
if (StringEqualNoCase(name, n)) return InstantiateStandardizedGroup<p>
@ -185,7 +185,7 @@ index dd69323b80076d7333b80453c9cc9ef5b680ce27..6431b768c83fa27b2287588e936f93ae
V("modp5", BN_get_rfc3526_prime_1536);
V("modp14", BN_get_rfc3526_prime_2048);
V("modp15", BN_get_rfc3526_prime_3072);
@@ -559,15 +556,20 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
@@ -558,15 +555,20 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
return EVPKeyCtxPointer();
}
@ -206,7 +206,7 @@ index dd69323b80076d7333b80453c9cc9ef5b680ce27..6431b768c83fa27b2287588e936f93ae
if (!param_ctx ||
EVP_PKEY_paramgen_init(param_ctx.get()) <= 0 ||
EVP_PKEY_CTX_set_dh_paramgen_prime_len(
@@ -581,6 +583,9 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
@@ -580,6 +582,9 @@ EVPKeyCtxPointer DhKeyGenTraits::Setup(DhKeyPairGenConfig* params) {
}
key_params = EVPKeyPointer(raw_params);
@ -241,7 +241,7 @@ index 3fa4a415dc911a13afd90dfb31c1ed4ad0fd268f..fa48dffc31342c44a1c1207b9d4c3dc7
return EVPKeyCtxPointer();
diff --git a/src/crypto/crypto_random.cc b/src/crypto/crypto_random.cc
index 9850104cd607f877a8e867e83a8d4d4ccd4a4395..f153b3366e2795133ff3df7b7a2153a6106237e4 100644
index 245f352918696413f8f0f7cec94dbcec687685af..35c1c1ce9f0e3d59b75e3966d485bf70b846de5b 100644
--- a/src/crypto/crypto_random.cc
+++ b/src/crypto/crypto_random.cc
@@ -140,7 +140,7 @@ Maybe<bool> RandomPrimeTraits::AdditionalConfig(
@ -254,7 +254,7 @@ index 9850104cd607f877a8e867e83a8d4d4ccd4a4395..f153b3366e2795133ff3df7b7a2153a6
THROW_ERR_CRYPTO_OPERATION_FAILED(env, "could not generate prime");
return Nothing<bool>();
diff --git a/src/crypto/crypto_rsa.cc b/src/crypto/crypto_rsa.cc
index 47a42246eddfc795b735f5efd08edf2832bbf6c1..7e6afaa1d3a4612fd567924b40438a318ac93bac 100644
index 3f8499457cf10765fa55e5018a26580f2c5ef15d..31647423be528949db744cbea43586ece5243bac 100644
--- a/src/crypto/crypto_rsa.cc
+++ b/src/crypto/crypto_rsa.cc
@@ -610,10 +610,11 @@ Maybe<bool> GetRsaKeyDetail(
@ -274,10 +274,10 @@ index 47a42246eddfc795b735f5efd08edf2832bbf6c1..7e6afaa1d3a4612fd567924b40438a31
if (target
diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
index 1cfebb5e41d35d1845ba8e40657d6e8798988223..2302e3bad99625eb5dd5587218d0a1985837fb8e 100644
index 5734d8fdc5505e1586f571c19b840bd56e9c9f1f..3034b114e081e2b32dd5b71653927a41af7d48df 100644
--- a/src/crypto/crypto_util.cc
+++ b/src/crypto/crypto_util.cc
@@ -518,24 +518,15 @@ Maybe<bool> Decorate(Environment* env, Local<Object> obj,
@@ -517,24 +517,15 @@ Maybe<bool> Decorate(Environment* env, Local<Object> obj,
V(BIO) \
V(PKCS7) \
V(X509V3) \
@ -303,7 +303,7 @@ index 1cfebb5e41d35d1845ba8e40657d6e8798988223..2302e3bad99625eb5dd5587218d0a198
V(USER) \
#define V(name) case ERR_LIB_##name: lib = #name "_"; break;
@@ -709,7 +700,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
@@ -715,7 +706,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsUint32());
Environment* env = Environment::GetCurrent(args);
uint32_t len = args[0].As<Uint32>()->Value();
@ -312,7 +312,7 @@ index 1cfebb5e41d35d1845ba8e40657d6e8798988223..2302e3bad99625eb5dd5587218d0a198
if (data == nullptr) {
// There's no memory available for the allocation.
// Return nothing.
@@ -720,7 +711,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
@@ -726,7 +717,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
data,
len,
[](void* data, size_t len, void* deleter_data) {
@ -321,7 +321,7 @@ index 1cfebb5e41d35d1845ba8e40657d6e8798988223..2302e3bad99625eb5dd5587218d0a198
},
data);
Local<ArrayBuffer> buffer = ArrayBuffer::New(env->isolate(), store);
@@ -728,10 +719,12 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
@@ -734,10 +725,12 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
}
void SecureHeapUsed(const FunctionCallbackInfo<Value>& args) {
@ -335,10 +335,10 @@ index 1cfebb5e41d35d1845ba8e40657d6e8798988223..2302e3bad99625eb5dd5587218d0a198
} // namespace
diff --git a/src/node_metadata.cc b/src/node_metadata.cc
index 6fe09f843e26b7f29faadf5035d368ed8b7eba38..326a9ee8a6d24d0c78537bfe5d9da394a439da90 100644
index 22546e9de25bdf95a00d06057626b544d5bf6f28..3a20f2f6a153c2f0b48b86ed83b92484ac4c274a 100644
--- a/src/node_metadata.cc
+++ b/src/node_metadata.cc
@@ -14,7 +14,7 @@
@@ -16,7 +16,7 @@
#include "v8.h"
#include "zlib.h"
@ -348,7 +348,7 @@ index 6fe09f843e26b7f29faadf5035d368ed8b7eba38..326a9ee8a6d24d0c78537bfe5d9da394
#if NODE_OPENSSL_HAS_QUIC
#include <openssl/quic.h>
diff --git a/src/node_metadata.h b/src/node_metadata.h
index 1831bfd0baaac70277fc274a72235bf6a04697cb..1c0a3fcdeb44dc947bb8c38459533779575379da 100644
index cf051585e779e2b03bd7b95fe5008b89cc7f8162..9de49c6828468fdf846dcd4ad445390f14446099 100644
--- a/src/node_metadata.h
+++ b/src/node_metadata.h
@@ -6,7 +6,7 @@
@ -361,7 +361,7 @@ index 1831bfd0baaac70277fc274a72235bf6a04697cb..1c0a3fcdeb44dc947bb8c38459533779
#if NODE_OPENSSL_HAS_QUIC
#include <openssl/quic.h>
diff --git a/src/node_options.cc b/src/node_options.cc
index 26f205bc3b425c5a6546a0ab27397754d6fe213d..397f9d4a7a8e9a850ae2e13b84d7f893076f724d 100644
index b544f1209143c0d4a01b1df3257e5b2ba1d5bfee..f711ac936e76f9c16d15d7db759d0081a9eb018d 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -6,7 +6,7 @@
@ -374,7 +374,7 @@ index 26f205bc3b425c5a6546a0ab27397754d6fe213d..397f9d4a7a8e9a850ae2e13b84d7f893
#endif
diff --git a/src/node_options.h b/src/node_options.h
index 7d210049aff445bd9b721dbded1ea299c514f415..864ed5673aa0aa30557e4c320c1eeb2b45e7defa 100644
index bc18a45e681a3cd8d26ea94862d7a6eb3a6631fc..08141c540c0c3fe4f2a4fe66bf75557a71a1d8e6 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -11,7 +11,7 @@

Просмотреть файл

@ -24,10 +24,10 @@ index 9f5340c223902c5ff61def05e8a4f470b4f328e8..d6dbfa482f9ebff3f99fb810e072cf9a
}
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
index be4d82086199855a10108528b3dacc663b839454..10c33bacc0529e12f52aaf1baf6d42489b2a75a7 100644
index 4460042d7bfbb8286a9b2abcbfb9e44f21b5d944..027a2de1878d5f09dc5d44b1b21af7163ea1b999 100644
--- a/lib/internal/main/worker_thread.js
+++ b/lib/internal/main/worker_thread.js
@@ -108,6 +108,7 @@ port.on('message', (message) => {
@@ -112,6 +112,7 @@ port.on('message', (message) => {
require('internal/worker').assignEnvironmentData(environmentData);

Просмотреть файл

@ -1,71 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Thu, 20 Jul 2023 14:18:19 -0500
Subject: fix: isURL() implementation
Modify Node's lib/internal/url.js isURL() to return the correct value for
URLs created both inside and outside of Node.
The isURL() impl in `main` is Electron-safe but can't be backported in
isolation because it relies on other changes from 18 to main. But we can
safely get there by trying the 18 version first (catching Node URLs),
then the `main` version (catching Electron URLs).
More background w/upstream links at
https://github.com/electron/electron/pull/39154#issuecomment-1644433388
This patch can be removed when we update to Node 20.
diff --git a/lib/internal/url.js b/lib/internal/url.js
index b66a5bbde3e8c419d5385339805cbd94f630986d..228122a38776fe5436f2601efa16b7aa2b440468 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -618,7 +618,12 @@ ObjectDefineProperties(URLSearchParams.prototype, {
* @returns {self is URL}
*/
function isURL(self) {
- return self != null && ObjectPrototypeHasOwnProperty(self, context);
+ // if it has `context` it is a Node.js URL...
+ if (self != null && ObjectPrototypeHasOwnProperty(self, context))
+ return true;
+
+ // ...but also honor 3rd party URLs e.g. from Electron.
+ return Boolean(self?.href && self.protocol && self.auth === undefined && self.path === undefined);
}
class URL {
@@ -715,14 +720,10 @@ class URL {
}
get href() {
- if (!isURL(this))
- throw new ERR_INVALID_THIS('URL');
return this[context].href;
}
set href(value) {
- if (!isURL(this))
- throw new ERR_INVALID_THIS('URL');
value = `${value}`;
const href = bindingUrl.update(this[context].href, updateActions.kHref, value);
if (!href) { throw ERR_INVALID_URL(value); }
diff --git a/test/parallel/test-whatwg-url-invalidthis.js b/test/parallel/test-whatwg-url-invalidthis.js
index 790c28e37c13ed6763cb61b549ab4a983f384717..bddf48b8302632a275d996a53b09343938dc7dc9 100644
--- a/test/parallel/test-whatwg-url-invalidthis.js
+++ b/test/parallel/test-whatwg-url-invalidthis.js
@@ -15,7 +15,6 @@ const assert = require('assert');
});
[
- 'href',
'protocol',
'username',
'password',
@@ -36,7 +35,6 @@ const assert = require('assert');
});
[
- 'origin',
'searchParams',
].forEach((i) => {
assert.throws(() => Reflect.get(URL.prototype, i, {}), {

Просмотреть файл

@ -6,62 +6,51 @@ 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 d8a072cf6af3b0d3a47ee69be04b26875683d261..7991703df940634c62d798210b5e7b94412f9bde 100644
index 14d5236d0ead946acf9a2f63bf979e7193bfbf56..74136abfb9aae1fc8ab746908be752056b6d7c5a 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -20,7 +20,7 @@ const experimentalNetworkImports =
const { Buffer: { from: BufferFrom } } = require('buffer');
-const { readFile: readFileAsync } = require('internal/fs/promises').exports;
@@ -10,7 +10,7 @@ const { kEmptyObject } = require('internal/util');
const { defaultGetFormat } = require('internal/modules/esm/get_format');
const { validateAssertions } = require('internal/modules/esm/assert');
const { getOptionValue } = require('internal/options');
-const { readFileSync } = require('fs');
+const fs = require('fs');
const { URL } = require('internal/url');
const {
ERR_INVALID_URL,
@@ -39,7 +39,7 @@ async function getSource(url, context) {
// Do not eagerly grab .manifest, it may be in TDZ
const policy = getOptionValue('--experimental-policy') ?
@@ -40,8 +40,7 @@ async function getSource(url, context) {
let responseURL = href;
let source;
if (protocol === 'file:') {
- const { readFile: readFileAsync } = require('internal/fs/promises').exports;
- source = await readFileAsync(url);
+ source = await fs.promises.readFile(url);
} else if (protocol === 'data:') {
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
if (!match) {
@@ -80,7 +79,7 @@ function getSourceSync(url, context) {
const responseURL = href;
let source;
if (protocol === 'file:') {
- source = readFileSync(url);
+ source = fs.readFileSync(url);
} else if (protocol === 'data:') {
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
if (!match) {
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
index a93d93b3c2aae3ef790ffa4f417d50b884451549..4072321e6bc3c9f0c8428d8159670950886c3404 100644
index acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62dcd760cce 100644
--- a/lib/internal/modules/esm/resolve.js
+++ b/lib/internal/modules/esm/resolve.js
@@ -26,11 +26,7 @@ const {
@@ -24,7 +24,7 @@ const {
} = primordials;
const internalFS = require('internal/fs/utils');
const { BuiltinModule } = require('internal/bootstrap/loaders');
-const {
- realpathSync,
- statSync,
- Stats,
-} = require('fs');
const { BuiltinModule } = require('internal/bootstrap/realm');
-const { realpathSync } = require('fs');
+const fs = require('fs');
const { getOptionValue } = require('internal/options');
const pendingDeprecation = getOptionValue('--pending-deprecation');
// Do not eagerly grab .manifest, it may be in TDZ
@@ -172,14 +168,14 @@ const realpathCache = new SafeMap();
* @returns {import('fs').Stats}
*/
const tryStatSync =
- (path) => statSync(path, { throwIfNoEntry: false }) ?? new Stats();
+ (path) => fs.statSync(path, { throwIfNoEntry: false }) ?? new fs.Stats();
/**
* @param {string | URL} url
* @returns {boolean}
*/
function fileExists(url) {
- return statSync(url, { throwIfNoEntry: false })?.isFile() ?? false;
+ return fs.statSync(url, { throwIfNoEntry: false })?.isFile() ?? false;
}
/**
@@ -329,7 +325,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
const policy = getOptionValue('--experimental-policy') ?
@@ -235,7 +235,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
}
if (!preserveSymlinks) {
@ -71,19 +60,19 @@ index a93d93b3c2aae3ef790ffa4f417d50b884451549..4072321e6bc3c9f0c8428d8159670950
});
const { search, hash } = resolved;
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 1ceb89da21610c703f4a18be5888373c7feaa370..347558c805c8ecd3f7ff4f6324ef7df68badc52f 100644
index 178f362b2869173d51b2e97a8d35a16ab4ed4962..4c3a0d8c484a402fe419a0bd45c7e2b1d717cb4a 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -24,7 +24,7 @@ function lazyTypes() {
return _TYPES = require('internal/util/types');
@@ -25,7 +25,7 @@ function lazyTypes() {
}
const assert = require('internal/assert');
-const { readFileSync } = require('fs');
+const fs = require('fs');
const { extname, isAbsolute } = require('path');
const { dirname, extname, isAbsolute } = require('path');
const {
hasEsmSyntax,
@@ -131,7 +131,7 @@ translators.set('module', async function moduleStrategy(url, source, isMain) {
@@ -132,7 +132,7 @@ translators.set('module', async function moduleStrategy(url, source, isMain) {
*/
function enrichCJSError(err, content, filename) {
if (err != null && ObjectGetPrototypeOf(err) === SyntaxErrorPrototype &&
@ -92,12 +81,21 @@ index 1ceb89da21610c703f4a18be5888373c7feaa370..347558c805c8ecd3f7ff4f6324ef7df6
// Emit the warning synchronously because we are in the middle of handling
// a SyntaxError that will throw and likely terminate the process before an
// asynchronous warning would be emitted.
@@ -207,7 +207,7 @@ function cjsPreparseModuleExports(filename) {
@@ -294,7 +294,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
let source;
try {
- source = readFileSync(filename, 'utf8');
+ source = fs.readFileSync(filename, 'utf8');
// We still need to read the FS to detect the exports.
- source ??= readFileSync(new URL(url), 'utf8');
+ source ??= fs.readFileSync(new URL(url), 'utf8');
} catch {
// Continue regardless of error.
}
@@ -357,7 +357,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).
- const source = readFileSync(resolved, 'utf-8');
+ const source = fs.readFileSync(resolved, 'utf-8');
const { exportNames: reexportNames } = cjsPreparseModuleExports(resolved, source);
for (const name of reexportNames)
exportNames.add(name);

Просмотреть файл

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 15 Nov 2023 12:25:39 +0100
Subject: fix: missing include for NODE_EXTERN
At some point it seems that node.h was removed from the include chain,
causing the following error:
../../third_party/electron_node/src/module_wrap.h:33:1: error: unknown type name 'NODE_EXTERN'
33 | NODE_EXTERN v8::MaybeLocal<v8::Promise> ImportModuleDynamically(
| ^
This should be upstreamed.
diff --git a/src/module_wrap.h b/src/module_wrap.h
index c51eb99ce3eb54bc30ae922e0357b637b09d53c6..55317ced78ee9ceaa13f7e00477c59370eb335fa 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
#include "base_object.h"
+#include "node.h"
namespace node {

Просмотреть файл

@ -1,39 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Keeley Hammond <khammond@slack-corp.com>
Date: Tue, 2 Aug 2022 12:52:02 -0700
Subject: fix: override createjob in node_platform
Refs https://github.com/nodejs/node/pull/44741/commits/507dd20ef957acf261ec521fcbd81d745b17983c
V8Platform::CreateJob was changed to an abstract method in https://chromium-review.googlesource.com/c/v8/v8/+/3779694,
and is called by V8Platform::PostJob, so we should only call
CreateJob in order to most closely match V8Platform default behavior.
This patch can be removed when Electron updates to Node.js v20.
diff --git a/src/node_platform.cc b/src/node_platform.cc
index 7dd0526e6ece5fd86ab3847be592e778e48b5d37..a20622adb2ee8a2e3b05b336e481193624d5b810 100644
--- a/src/node_platform.cc
+++ b/src/node_platform.cc
@@ -528,7 +528,7 @@ bool NodePlatform::FlushForegroundTasks(Isolate* isolate) {
return per_isolate->FlushForegroundTasksInternal();
}
-std::unique_ptr<v8::JobHandle> NodePlatform::PostJob(v8::TaskPriority priority,
+std::unique_ptr<v8::JobHandle> NodePlatform::CreateJob(v8::TaskPriority priority,
std::unique_ptr<v8::JobTask> job_task) {
return v8::platform::NewDefaultJobHandle(
this, priority, std::move(job_task), NumberOfWorkerThreads());
diff --git a/src/node_platform.h b/src/node_platform.h
index 4a05f3bba58c8e875d0ab67f292589edbb3b812b..1062f3b1b9c386a7bde8dca366c6f008bb183ab7 100644
--- a/src/node_platform.h
+++ b/src/node_platform.h
@@ -155,7 +155,7 @@ class NodePlatform : public MultiIsolatePlatform {
double CurrentClockTimeMillis() override;
v8::TracingController* GetTracingController() override;
bool FlushForegroundTasks(v8::Isolate* isolate) override;
- std::unique_ptr<v8::JobHandle> PostJob(
+ std::unique_ptr<v8::JobHandle> CreateJob(
v8::TaskPriority priority,
std::unique_ptr<v8::JobTask> job_task) override;

Просмотреть файл

@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Rose <japthorp@slack-corp.com>
Date: Thu, 29 Sep 2022 16:30:17 -0700
Subject: fix parallel/test-v8-stats
Refs https://chromium-review.googlesource.com/c/v8/v8/+/3967841
Refs https://chromium-review.googlesource.com/c/v8/v8/+/3892950.
Heap spaces were added/removed in v8 - this patch updates test expectations
to match.
This patch can be removed when Electron updates to Node.js v20.
diff --git a/test/parallel/test-v8-stats.js b/test/parallel/test-v8-stats.js
index 2eaa3c5b0609149271afb85d7ecc33272e0ada2e..83b375bd3c5b5dbd5189d48ad560580883ac91f6 100644
--- a/test/parallel/test-v8-stats.js
+++ b/test/parallel/test-v8-stats.js
@@ -42,11 +42,12 @@ const expectedHeapSpaces = [
'code_large_object_space',
'code_space',
'large_object_space',
- 'map_space',
'new_large_object_space',
'new_space',
'old_space',
'read_only_space',
+ 'shared_large_object_space',
+ 'shared_space'
];
const heapSpaceStatistics = v8.getHeapSpaceStatistics();
const actualHeapSpaceNames = heapSpaceStatistics.map((s) => s.space_name);

Просмотреть файл

@ -6,10 +6,10 @@ 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 99432053cc3b242e514268b7aba2e2d83a9e64f2..750a5424953aad104ba1e865fefd55d316485917 100644
index f6ec79cd57b5010ed5fd6829d952bcdacc8b7671..5cda078a55f7825d135a107fa98e1aa3527dd147 100644
--- a/deps/uv/src/win/util.c
+++ b/deps/uv/src/win/util.c
@@ -1743,10 +1743,17 @@ int uv_os_uname(uv_utsname_t* buffer) {
@@ -1685,10 +1685,17 @@ int uv_os_uname(uv_utsname_t* buffer) {
#ifdef _MSC_VER
#pragma warning(suppress : 4996)
#endif

Просмотреть файл

@ -1,33 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: John Kleinschmidt <jkleinsc@electronjs.org>
Date: Thu, 26 May 2022 17:08:33 -0400
Subject: JSON.parse errors made user-friendly
Update tests for https://chromium-review.googlesource.com/c/v8/v8/+/3513684
diff --git a/test/es-module/test-esm-data-urls.js b/test/es-module/test-esm-data-urls.js
index 5be45d0f7af3b6dd483fe3b185c76e41a1bf533b..a99dde30c3d977dfc226a33f632f5f69638892af 100644
--- a/test/es-module/test-esm-data-urls.js
+++ b/test/es-module/test-esm-data-urls.js
@@ -76,7 +76,7 @@ function createBase64URL(mime, body) {
import('data:application/json;foo="test,",0',
{ assert: { type: 'json' } }), {
name: 'SyntaxError',
- message: /Unexpected end of JSON input/
+ message: 'data:application/json;foo="test,",0: Unterminated string in JSON at position 3 (line 1 column 4)'
});
}
{
diff --git a/test/es-module/test-esm-invalid-pjson.js b/test/es-module/test-esm-invalid-pjson.js
index f3a38018637aa349ad79617ab9835e61d7058fe9..bc78b870c84c4baedecdd7ffc1157c86c307cebf 100644
--- a/test/es-module/test-esm-invalid-pjson.js
+++ b/test/es-module/test-esm-invalid-pjson.js
@@ -18,7 +18,7 @@ describe('ESM: Package.json', { concurrency: true }, () => {
stderr.includes(
`[ERR_INVALID_PACKAGE_CONFIG]: Invalid package config ${invalidJson} ` +
`while importing "invalid-pjson" from ${entry}. ` +
- `Unexpected token } in JSON at position ${12 + checkoutEOL.length * 2}`
+ `Expected ':' after property name in JSON at position ${12 + checkoutEOL.length * 2}`
),
stderr
);

Просмотреть файл

@ -1,44 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 27 Feb 2023 12:56:15 +0100
Subject: lib: fix BroadcastChannel initialization location
Refs https://github.com/nodejs/node/pull/40532.
Fixes a bug in the above, wherein BroadcastChannel should have been
initialized in bootstrap/browser instead of bootstrap/node. That
inadvertently made it such that there was incorrect handling of the
DOM vs Node.js implementations of BroadcastChannel.
This will be upstreamed.
diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js
index 5be4dd6176482c724455cbbeeaa9680e849a091b..29ccee75d77da072735032f0a25363ac88a023ba 100644
--- a/lib/internal/bootstrap/browser.js
+++ b/lib/internal/bootstrap/browser.js
@@ -12,6 +12,10 @@ const {
} = require('internal/util');
const config = internalBinding('config');
+// Non-standard extensions:
+const { BroadcastChannel } = require('internal/worker/io');
+exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel);
+
// https://console.spec.whatwg.org/#console-namespace
exposeNamespace(globalThis, 'console',
createGlobalConsole());
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 13ea68c96fd415f976aab0f291a1b7c688db1c58..0ca3de08fffb344c0330ce0f8d28b2d3d0b24350 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -238,10 +238,6 @@ const {
queueMicrotask,
} = require('internal/process/task_queues');
-// Non-standard extensions:
-const { BroadcastChannel } = require('internal/worker/io');
-exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel);
-
defineOperation(globalThis, 'queueMicrotask', queueMicrotask);
const timers = require('timers');

Просмотреть файл

@ -16,11 +16,11 @@ Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
(cherry picked from commit a4fdb1abe0844d86b4cbfcc4051794656e7d746e)
diff --git a/lib/internal/blob.js b/lib/internal/blob.js
index a25f6cf7df23875a5cefc0a4f92a997494a313af..58d2193195d9523d3bc43054efbbe4eebb0c7b05 100644
index d0e47c1a4397a875c937d43c3b72dbd1e1de35a7..400d2c5fd21bc962a8befc4d80527216baddd6d5 100644
--- a/lib/internal/blob.js
+++ b/lib/internal/blob.js
@@ -25,6 +25,9 @@ const {
FixedSizeBlobCopyJob,
@@ -24,6 +24,9 @@ const {
concat,
getDataObject,
} = internalBinding('blob');
+const {
@ -29,7 +29,7 @@ index a25f6cf7df23875a5cefc0a4f92a997494a313af..58d2193195d9523d3bc43054efbbe4ee
const {
TextDecoder,
@@ -61,7 +64,6 @@ const {
@@ -62,7 +65,6 @@ const {
} = require('internal/errors');
const {
@ -37,7 +37,7 @@ index a25f6cf7df23875a5cefc0a4f92a997494a313af..58d2193195d9523d3bc43054efbbe4ee
validateDictionary,
} = require('internal/validators');
@@ -161,8 +163,8 @@ class Blob {
@@ -158,8 +160,8 @@ class Blob {
return src;
});
@ -98,11 +98,11 @@ index c6b728027057ece38c2b7fcc6bf7b18b959125d2..aad9c6bcab69e971c02281928885d94a
const b = Buffer.allocUnsafe(1024);
diff --git a/test/parallel/test-buffer-over-max-length.js b/test/parallel/test-buffer-over-max-length.js
index c263633d941cddc7614df7e7ec64ad9aaaa7864b..1167328131fcd59d973ccf38201f458441517636 100644
index d2df358cc00ca4b238252d6d11bdad3b77fad114..f29d6b62d4aa408fb3a67ffe71b14436fbbff907 100644
--- a/test/parallel/test-buffer-over-max-length.js
+++ b/test/parallel/test-buffer-over-max-length.js
@@ -13,18 +13,8 @@ const bufferMaxSizeMsg = {
message: /^The argument 'size' is invalid\. Received [^"]*$/
@@ -12,18 +12,8 @@ const bufferMaxSizeMsg = {
name: 'RangeError',
};
-assert.throws(() => Buffer((-1 >>> 0) + 2), bufferMaxSizeMsg);
@ -121,10 +121,10 @@ index c263633d941cddc7614df7e7ec64ad9aaaa7864b..1167328131fcd59d973ccf38201f4584
-assert.throws(() => Buffer.allocUnsafe(0x100000001), bufferMaxSizeMsg);
-assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFFF), bufferMaxSizeMsg);
diff --git a/test/parallel/test-buffer-tostring-rangeerror.js b/test/parallel/test-buffer-tostring-rangeerror.js
index 4416effb422ac4a000eff1732cbfeeffcc567555..0ebea759b5c42be0c294093256ea3cad7034a98b 100644
index d2e1e0d6e46438f20d6b8f1196ebd936d4fa3436..0ebea759b5c42be0c294093256ea3cad7034a98b 100644
--- a/test/parallel/test-buffer-tostring-rangeerror.js
+++ b/test/parallel/test-buffer-tostring-rangeerror.js
@@ -1,18 +1,22 @@
@@ -1,17 +1,22 @@
'use strict';
require('../common');
@ -146,9 +146,8 @@ index 4416effb422ac4a000eff1732cbfeeffcc567555..0ebea759b5c42be0c294093256ea3cad
-const len = 1422561062959;
+const len = MAX_STRING_LENGTH + 1;
const message = {
- code: 'ERR_INVALID_ARG_VALUE',
- code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError',
- message: /^The argument 'size' is invalid\. Received [^"]*$/
+ code: 'ERR_STRING_TOO_LONG',
+ name: 'Error',
};

Просмотреть файл

@ -1,171 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tim Perry <pimterry@gmail.com>
Date: Thu, 24 Aug 2023 16:05:02 +0100
Subject: net: fix crash due to simultaneous close/shutdown on JS Stream
Sockets
A JS stream socket wraps a stream, exposing it as a socket for something
on top which needs a socket specifically (e.g. an HTTP server).
If the internal stream is closed in the same tick as the layer on top
attempts to close this stream, the race between doShutdown and doClose
results in an uncatchable exception. A similar race can happen with
doClose and doWrite.
It seems legitimate these can happen in parallel, so this resolves that
by explicitly detecting and handling that situation: if a close is in
progress, both doShutdown & doWrite allow doClose to run
finishShutdown/Write for them, cancelling the operation, without trying
to use this._handle (which will be null) in the meantime.
PR-URL: https://github.com/nodejs/node/pull/49400
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js
index 8bc19296620b3fd0e5487165743f0f1bc2d342e7..68e1802a63b012b59418b79a0e68de5147543a23 100644
--- a/lib/internal/js_stream_socket.js
+++ b/lib/internal/js_stream_socket.js
@@ -21,6 +21,7 @@ const { ERR_STREAM_WRAP } = require('internal/errors').codes;
const kCurrentWriteRequest = Symbol('kCurrentWriteRequest');
const kCurrentShutdownRequest = Symbol('kCurrentShutdownRequest');
const kPendingShutdownRequest = Symbol('kPendingShutdownRequest');
+const kPendingClose = Symbol('kPendingClose');
function isClosing() { return this[owner_symbol].isClosing(); }
@@ -94,6 +95,7 @@ class JSStreamSocket extends Socket {
this[kCurrentWriteRequest] = null;
this[kCurrentShutdownRequest] = null;
this[kPendingShutdownRequest] = null;
+ this[kPendingClose] = false;
this.readable = stream.readable;
this.writable = stream.writable;
@@ -135,10 +137,17 @@ class JSStreamSocket extends Socket {
this[kPendingShutdownRequest] = req;
return 0;
}
+
assert(this[kCurrentWriteRequest] === null);
assert(this[kCurrentShutdownRequest] === null);
this[kCurrentShutdownRequest] = req;
+ if (this[kPendingClose]) {
+ // If doClose is pending, the stream & this._handle are gone. We can't do
+ // anything. doClose will call finishShutdown with ECANCELED for us shortly.
+ return 0;
+ }
+
const handle = this._handle;
process.nextTick(() => {
@@ -164,6 +173,13 @@ class JSStreamSocket extends Socket {
assert(this[kCurrentWriteRequest] === null);
assert(this[kCurrentShutdownRequest] === null);
+ if (this[kPendingClose]) {
+ // If doClose is pending, the stream & this._handle are gone. We can't do
+ // anything. doClose will call finishWrite with ECANCELED for us shortly.
+ this[kCurrentWriteRequest] = req; // Store req, for doClose to cancel
+ return 0;
+ }
+
const handle = this._handle;
const self = this;
@@ -217,6 +233,8 @@ class JSStreamSocket extends Socket {
}
doClose(cb) {
+ this[kPendingClose] = true;
+
const handle = this._handle;
// When sockets of the "net" module destroyed, they will call
@@ -234,6 +252,8 @@ class JSStreamSocket extends Socket {
this.finishWrite(handle, uv.UV_ECANCELED);
this.finishShutdown(handle, uv.UV_ECANCELED);
+ this[kPendingClose] = false;
+
cb();
});
}
diff --git a/test/parallel/test-http2-client-connection-tunnelling.js b/test/parallel/test-http2-client-connection-tunnelling.js
new file mode 100644
index 0000000000000000000000000000000000000000..6e04121ca71ea81f49c7f50ec11d7fac735c80a9
--- /dev/null
+++ b/test/parallel/test-http2-client-connection-tunnelling.js
@@ -0,0 +1,71 @@
+'use strict';
+
+const common = require('../common');
+const fixtures = require('../common/fixtures');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+const assert = require('assert');
+const net = require('net');
+const tls = require('tls');
+const h2 = require('http2');
+
+// This test sets up an H2 proxy server, and tunnels a request over one of its streams
+// back to itself, via TLS, and then closes the TLS connection. On some Node versions
+// (v18 & v20 up to 20.5.1) the resulting JS Stream Socket fails to shutdown correctly
+// in this case, and crashes due to a null pointer in finishShutdown.
+
+const tlsOptions = {
+ key: fixtures.readKey('agent1-key.pem'),
+ cert: fixtures.readKey('agent1-cert.pem'),
+ ALPNProtocols: ['h2']
+};
+
+const netServer = net.createServer((socket) => {
+ socket.allowHalfOpen = false;
+ // ^ This allows us to trigger this reliably, but it's not strictly required
+ // for the bug and crash to happen, skipping this just fails elsewhere later.
+
+ h2Server.emit('connection', socket);
+});
+
+const h2Server = h2.createSecureServer(tlsOptions, (req, res) => {
+ res.writeHead(200);
+ res.end();
+});
+
+h2Server.on('connect', (req, res) => {
+ res.writeHead(200, {});
+ netServer.emit('connection', res.stream);
+});
+
+netServer.listen(0, common.mustCall(() => {
+ const proxyClient = h2.connect(`https://localhost:${netServer.address().port}`, {
+ rejectUnauthorized: false
+ });
+
+ const proxyReq = proxyClient.request({
+ ':method': 'CONNECT',
+ ':authority': 'example.com:443'
+ });
+
+ proxyReq.on('response', common.mustCall((response) => {
+ assert.strictEqual(response[':status'], 200);
+
+ // Create a TLS socket within the tunnel, and start sending a request:
+ const tlsSocket = tls.connect({
+ socket: proxyReq,
+ ALPNProtocols: ['h2'],
+ rejectUnauthorized: false
+ });
+
+ proxyReq.on('close', common.mustCall(() => {
+ proxyClient.close();
+ netServer.close();
+ }));
+
+ // Forcibly kill the TLS socket
+ tlsSocket.destroy();
+
+ // This results in an async error in affected Node versions, before the 'close' event
+ }));
+}));

Просмотреть файл

@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tim Perry <pimterry@gmail.com>
Date: Fri, 25 Aug 2023 14:16:35 +0100
Subject: net: use asserts in JS Socket Stream to catch races in future
PR-URL: https://github.com/nodejs/node/pull/49400
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js
index 68e1802a63b012b59418b79a0e68de5147543a23..70d6d03069f3f1e85e66864c6c1e6de6084f5ea6 100644
--- a/lib/internal/js_stream_socket.js
+++ b/lib/internal/js_stream_socket.js
@@ -149,6 +149,7 @@ class JSStreamSocket extends Socket {
}
const handle = this._handle;
+ assert(handle !== null);
process.nextTick(() => {
// Ensure that write is dispatched asynchronously.
@@ -181,6 +182,8 @@ class JSStreamSocket extends Socket {
}
const handle = this._handle;
+ assert(handle !== null);
+
const self = this;
let pending = bufs.length;

Просмотреть файл

@ -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 88bb870a8fd2e5458cd47f76dc88b952de6c0303..4aa672675b5cf16b609d81d360e8be8c1a345bd8 100644
index 19a7d7e671f5abfa55b62290dcf3796a2c4e9013..3161afa33889f1682a1689e76fbcadc397f4b01c 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -142,6 +142,13 @@ const {
@ -23,7 +23,7 @@ index 88bb870a8fd2e5458cd47f76dc88b952de6c0303..4aa672675b5cf16b609d81d360e8be8c
const {
isProxy,
} = require('internal/util/types');
@@ -1251,10 +1258,12 @@ Module.prototype._compile = function(content, filename) {
@@ -1236,10 +1243,12 @@ Module.prototype._compile = function(content, filename) {
if (requireDepth === 0) statCache = new SafeMap();
if (inspectorWrapper) {
result = inspectorWrapper(compiledWrapper, thisValue, exports,

Просмотреть файл

@ -7,10 +7,10 @@ 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 07c6d5e9351a96aeca1179c20287dc3fb7ec1eab..13ea68c96fd415f976aab0f291a1b7c688db1c58 100644
index 7a773d5208e250abd8b0efb6dde66c45060bbee4..45e38ca0a122e3b1c5d8d59865f9610c19bdbd54 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -101,6 +101,10 @@ process.domain = null;
@@ -134,6 +134,10 @@ process.domain = null;
}
process._exiting = false;
@ -18,23 +18,23 @@ index 07c6d5e9351a96aeca1179c20287dc3fb7ec1eab..13ea68c96fd415f976aab0f291a1b7c6
+// internalBinding is not leaked to user code.
+process.internalBinding = internalBinding;
+
// TODO(@jasnell): Once this has gone through one full major
// release cycle, remove the Proxy and setter and update the
// getter to either return a read-only object or always return
// process.config is serialized config.gypi
const binding = internalBinding('builtins');
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 4aa672675b5cf16b609d81d360e8be8c1a345bd8..001343b74ce236f89dca030c0fc9dd0299df0b39 100644
index 3161afa33889f1682a1689e76fbcadc397f4b01c..84fea979d482d3d5cacfad4b09237e6345675cad 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -94,7 +94,7 @@ const fs = require('fs');
@@ -91,7 +91,7 @@ const fs = require('fs');
const internalFS = require('internal/fs/utils');
const path = require('path');
const { sep } = path;
-const { internalModuleStat } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const packageJsonReader = require('internal/modules/package_json_reader');
const { safeGetenv } = internalBinding('credentials');
const {
@@ -190,7 +190,7 @@ function stat(filename) {
privateSymbols: {
@@ -182,7 +182,7 @@ function stat(filename) {
const result = statCache.get(filename);
if (result !== undefined) return result;
}
@ -44,24 +44,24 @@ index 4aa672675b5cf16b609d81d360e8be8c1a345bd8..001343b74ce236f89dca030c0fc9dd02
// Only set cache when `internalModuleStat(filename)` succeeds.
statCache.set(filename, result);
diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js
index bb175d0df54c043075103dd394fd1f52c911e8dd..09ced1246cb6a8c2df764893c077177d23cb0414 100644
index c6377faae6f5a827fc9b5c271ebc85f2df2f7177..8143e83ee39a03871642cfd6e7b8671fc4c3454d 100644
--- a/lib/internal/modules/package_json_reader.js
+++ b/lib/internal/modules/package_json_reader.js
@@ -1,7 +1,7 @@
'use strict';
const { SafeMap } = primordials;
@@ -8,7 +8,7 @@ const {
const {
ERR_INVALID_PACKAGE_CONFIG,
} = require('internal/errors').codes;
-const { internalModuleReadJSON } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const { pathToFileURL } = require('url');
const { toNamespacedPath } = require('path');
const { kEmptyObject } = require('internal/util');
@@ -18,7 +18,7 @@ function read(jsonPath) {
return cache.get(jsonPath);
}
- const { 0: string, 1: containsKeys } = internalModuleReadJSON(
+ const { 0: string, 1: containsKeys } = internalFsBinding.internalModuleReadJSON(
@@ -48,7 +48,7 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
const {
0: string,
1: containsKeys,
- } = internalModuleReadJSON(
+ } = internalFsBinding.internalModuleReadJSON(
toNamespacedPath(jsonPath),
);
const result = { string, containsKeys };
const result = {

Просмотреть файл

@ -7,7 +7,7 @@ Subject: refactor: alter child_process.fork to use execute script with
When forking a child script, we setup a special environment to make the Electron binary run like the upstream node. On Mac, we use the helper app as node binary.
diff --git a/lib/child_process.js b/lib/child_process.js
index 5bdc474c80169cb0ceeb082e6afcf9e8fa322ab3..ec39a00ddb791e6e1ebe31aa45d290e7dcc4ebfc 100644
index 449013906e93e59568a90264d5372a3962db6cb0..9dd33ecbac3a5d516f9bff76fdbe1a8aece531f2 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -139,6 +139,14 @@ function fork(modulePath, args = [], options) {

Просмотреть файл

@ -7,10 +7,10 @@ Subject: src: adapt to v8::Exception API change
Cherry picked fix from https://github.com/nodejs/node-v8/commit/675f411677c28a10a2f03d4b3ef14c2284c33587
diff --git a/src/env-inl.h b/src/env-inl.h
index debd982c75805c51ea7d01229b9d635550060503..103dc6711e71e15da640edc5e017bc638ddc6ad1 100644
index 222c78ef0cb9904742fd44f8182278ab1f50cd59..e248a144b905a6c7c166796cddfe8442f8dc7158 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -730,10 +730,10 @@ inline void Environment::ThrowRangeError(const char* errmsg) {
@@ -780,10 +780,10 @@ inline void Environment::ThrowRangeError(const char* errmsg) {
}
inline void Environment::ThrowError(
@ -24,15 +24,15 @@ index debd982c75805c51ea7d01229b9d635550060503..103dc6711e71e15da640edc5e017bc63
inline void Environment::ThrowErrnoException(int errorno,
diff --git a/src/env.h b/src/env.h
index 45a9a7811b4abe1effb6acf2c89a772a7c2256c9..36e8e7d960a95a9040ad963c79a7f66c89233c87 100644
index 87df6e1f32e584aa0c6ae21856299fff31d67669..c9a455be8c395a2f231f56e0a54211466362aa1d 100644
--- a/src/env.h
+++ b/src/env.h
@@ -956,7 +956,7 @@ class Environment : public MemoryRetainer {
inline void RemoveHeapSnapshotNearHeapLimitCallback(size_t heap_limit);
@@ -1017,7 +1017,7 @@ class Environment : public MemoryRetainer {
};
private:
- inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
+ inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>, v8::Local<v8::Value>),
const char* errmsg);
std::list<binding::DLib> loaded_addons_;
void TrackContext(v8::Local<v8::Context> context);
void UntrackContext(v8::Local<v8::Context> context);

Просмотреть файл

@ -0,0 +1,91 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Keeley Hammond <vertedinde@electronjs.org>
Date: Mon, 6 Nov 2023 14:37:50 -0800
Subject: src: avoid copying string in fs_permission
Ref: https://github.com/nodejs/node/pull/47746/files
diff --git a/src/permission/fs_permission.cc b/src/permission/fs_permission.cc
index fadf75968c779d5aee8d9d1ee27e7b4abf241240..d407d440d74c66d9dc8ca4d4653096292c5adc4c 100644
--- a/src/permission/fs_permission.cc
+++ b/src/permission/fs_permission.cc
@@ -199,18 +199,18 @@ bool FSPermission::RadixTree::Lookup(const std::string_view& s,
}
}
-void FSPermission::RadixTree::Insert(const std::string& path) {
+void FSPermission::RadixTree::Insert(const std::string& path_prefix) {
FSPermission::RadixTree::Node* current_node = root_node_;
unsigned int parent_node_prefix_len = current_node->prefix.length();
- int path_len = path.length();
+ int path_len = path_prefix.length();
for (int i = 1; i <= path_len; ++i) {
- bool is_wildcard_node = path[i - 1] == '*';
+ bool is_wildcard_node = path_prefix[i - 1] == '*';
bool is_last_char = i == path_len;
if (is_wildcard_node || is_last_char) {
- std::string node_path = path.substr(parent_node_prefix_len, i);
+ std::string node_path = path_prefix.substr(parent_node_prefix_len, i);
current_node = current_node->CreateChild(node_path);
}
@@ -222,7 +222,7 @@ void FSPermission::RadixTree::Insert(const std::string& path) {
if (UNLIKELY(per_process::enabled_debug_list.enabled(
DebugCategory::PERMISSION_MODEL))) {
- per_process::Debug(DebugCategory::PERMISSION_MODEL, "Inserting %s\n", path);
+ per_process::Debug(DebugCategory::PERMISSION_MODEL, "Inserting %s\n", path_prefix);
PrintTree(root_node_);
}
}
diff --git a/src/permission/fs_permission.h b/src/permission/fs_permission.h
index 244e95727ad48757995c6404f457f42a4ba33ccd..4b6aab197333928bfbd5143bea15b3a5abd6d4c0 100644
--- a/src/permission/fs_permission.h
+++ b/src/permission/fs_permission.h
@@ -31,16 +31,16 @@ class FSPermission final : public PermissionBase {
Node() : wildcard_child(nullptr), is_leaf(false) {}
- Node* CreateChild(std::string prefix) {
- if (prefix.empty() && !is_leaf) {
+ Node* CreateChild(std::string path_prefix) {
+ if (path_prefix.empty() && !is_leaf) {
is_leaf = true;
return this;
}
- char label = prefix[0];
+ char label = path_prefix[0];
Node* child = children[label];
if (child == nullptr) {
- children[label] = new Node(prefix);
+ children[label] = new Node(path_prefix);
return children[label];
}
@@ -48,7 +48,7 @@ class FSPermission final : public PermissionBase {
unsigned int i = 0;
unsigned int prefix_len = prefix.length();
for (; i < child->prefix.length(); ++i) {
- if (i > prefix_len || prefix[i] != child->prefix[i]) {
+ if (i > prefix_len || path_prefix[i] != child->prefix[i]) {
std::string parent_prefix = child->prefix.substr(0, i);
std::string child_prefix = child->prefix.substr(i);
@@ -57,11 +57,11 @@ class FSPermission final : public PermissionBase {
split_child->children[child_prefix[0]] = child;
children[parent_prefix[0]] = split_child;
- return split_child->CreateChild(prefix.substr(i));
+ return split_child->CreateChild(path_prefix.substr(i));
}
}
child->is_leaf = true;
- return child->CreateChild(prefix.substr(i));
+ return child->CreateChild(path_prefix.substr(i));
}
Node* CreateWildcardChild() {

Просмотреть файл

@ -1,113 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Joyee Cheung <joyeec9h3@gmail.com>
Date: Wed, 2 Aug 2023 04:14:35 +0200
Subject: src: cast v8::Object::GetInternalField() return value to v8::Value
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In preparation of https://chromium-review.googlesource.com/c/v8/v8/+/4707972
which changes the return value to v8::Data.
PR-URL: https://github.com/nodejs/node/pull/48943
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
diff --git a/src/base_object-inl.h b/src/base_object-inl.h
index f003f1390b864f2f3874ec144b413fe5cec2dc56..0148c75427985e2ff034fafb15f3ac4604b48734 100644
--- a/src/base_object-inl.h
+++ b/src/base_object-inl.h
@@ -127,7 +127,8 @@ template <int Field>
void BaseObject::InternalFieldGet(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().Set(info.This()->GetInternalField(Field));
+ info.GetReturnValue().Set(
+ info.This()->GetInternalField(Field).As<v8::Value>());
}
template <int Field, bool (v8::Value::* typecheck)() const>
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index e0f1b2d51f3055b2250f2c0dc1dfd1048b645dd9..d2d9e06da8da068bb53f8d9a656e912d8b1fff3d 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -77,7 +77,7 @@ ModuleWrap::~ModuleWrap() {
}
Local<Context> ModuleWrap::context() const {
- Local<Value> obj = object()->GetInternalField(kContextObjectSlot);
+ Local<Value> obj = object()->GetInternalField(kContextObjectSlot).As<Value>();
if (obj.IsEmpty()) return {};
return obj.As<Object>()->GetCreationContext().ToLocalChecked();
}
@@ -685,7 +685,9 @@ MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(
TryCatchScope try_catch(env);
Local<Function> synthetic_evaluation_steps =
- obj->object()->GetInternalField(kSyntheticEvaluationStepsSlot)
+ obj->object()
+ ->GetInternalField(kSyntheticEvaluationStepsSlot)
+ .As<Value>()
.As<Function>();
obj->object()->SetInternalField(
kSyntheticEvaluationStepsSlot, Undefined(isolate));
diff --git a/src/node_file.cc b/src/node_file.cc
index 4993da585322dbe9f4faec986ae36d4f215b35af..c0507777273cff6ef781dd9e09e1423e92a431aa 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -439,7 +439,7 @@ MaybeLocal<Promise> FileHandle::ClosePromise() {
Local<Context> context = env()->context();
Local<Value> close_resolver =
- object()->GetInternalField(FileHandle::kClosingPromiseSlot);
+ object()->GetInternalField(FileHandle::kClosingPromiseSlot).As<Value>();
if (!close_resolver.IsEmpty() && !close_resolver->IsUndefined()) {
CHECK(close_resolver->IsPromise());
return close_resolver.As<Promise>();
diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc
index 5d0e2b0d4c7ba16f920176ac42a33d70610f273e..1a0cb082a2534f17233d0557e95837b2ce79d43b 100644
--- a/src/node_task_queue.cc
+++ b/src/node_task_queue.cc
@@ -50,7 +50,7 @@ static Maybe<double> GetAssignedPromiseWrapAsyncId(Environment* env,
// be an object. If it's not, we just ignore it. Ideally v8 would
// have had GetInternalField returning a MaybeLocal but this works
// for now.
- Local<Value> promiseWrap = promise->GetInternalField(0);
+ Local<Value> promiseWrap = promise->GetInternalField(0).As<Value>();
if (promiseWrap->IsObject()) {
Local<Value> maybe_async_id;
if (!promiseWrap.As<Object>()->Get(env->context(), id_symbol)
diff --git a/src/node_zlib.cc b/src/node_zlib.cc
index fac116f9e6b3e23451c812be0a123fe6368fb3df..0c4ae0fc794347be49502977d8a375ff1007a605 100644
--- a/src/node_zlib.cc
+++ b/src/node_zlib.cc
@@ -423,7 +423,8 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
UpdateWriteResult();
// call the write() cb
- Local<Value> cb = object()->GetInternalField(kWriteJSCallback);
+ Local<Value> cb =
+ object()->GetInternalField(kWriteJSCallback).template As<Value>();
MakeCallback(cb.As<Function>(), 0, nullptr);
if (pending_close_)
diff --git a/src/stream_base.cc b/src/stream_base.cc
index f1769ca52970fed7267fed4df29aee0803faa859..b9dfc645e2b49c73822fc7277f296d028699de05 100644
--- a/src/stream_base.cc
+++ b/src/stream_base.cc
@@ -470,8 +470,9 @@ MaybeLocal<Value> StreamBase::CallJSOnreadMethod(ssize_t nread,
AsyncWrap* wrap = GetAsyncWrap();
CHECK_NOT_NULL(wrap);
- Local<Value> onread = wrap->object()->GetInternalField(
- StreamBase::kOnReadFunctionField);
+ Local<Value> onread = wrap->object()
+ ->GetInternalField(StreamBase::kOnReadFunctionField)
+ .As<Value>();
CHECK(onread->IsFunction());
return wrap->MakeCallback(onread.As<Function>(), arraysize(argv), argv);
}

Просмотреть файл

@ -0,0 +1,148 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Mon, 13 Nov 2023 22:01:07 +0900
Subject: src: fix compatility with upcoming V8 12.1 APIs
In the upcoming V8 11.10 there are a few API changes will break
building of Node, this PR makes the code compatible with both old
and new APIs.
This PR is needed because [V8's node-ci repo](https://chromium.googlesource.com/v8/node-ci/)
tests latest Node with latest V8, and without this change V8 has to patch Node in
their own fork.
diff --git a/src/env-inl.h b/src/env-inl.h
index e248a144b905a6c7c166796cddfe8442f8dc7158..524a9633ef16e48797dc6a1e507ca0be2bfffe7e 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -779,9 +779,14 @@ inline void Environment::ThrowRangeError(const char* errmsg) {
ThrowError(v8::Exception::RangeError, errmsg);
}
-inline void Environment::ThrowError(
- v8::Local<v8::Value> (*fun)(v8::Local<v8::String>, v8::Local<v8::Value>),
- const char* errmsg) {
+inline void Environment::ThrowError(V8ExceptionConstructorOld fun,
+ const char* errmsg) {
+ v8::HandleScope handle_scope(isolate());
+ isolate()->ThrowException(fun(OneByteString(isolate(), errmsg)));
+ }
+
+inline void Environment::ThrowError(V8ExceptionConstructorNew fun,
+ const char* errmsg) {
v8::HandleScope handle_scope(isolate());
isolate()->ThrowException(fun(OneByteString(isolate(), errmsg), {}));
}
diff --git a/src/env.h b/src/env.h
index c9a455be8c395a2f231f56e0a54211466362aa1d..448075e354c760a2dbd1dd763f40b7a645730250 100644
--- a/src/env.h
+++ b/src/env.h
@@ -1017,8 +1017,14 @@ class Environment : public MemoryRetainer {
};
private:
- inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>, v8::Local<v8::Value>),
- const char* errmsg);
+ // V8 has changed the constructor of exceptions, support both APIs before Node
+ // updates to V8 12.1.
+ using V8ExceptionConstructorOld =
+ v8::Local<v8::Value> (*)(v8::Local<v8::String>);
+ using V8ExceptionConstructorNew =
+ v8::Local<v8::Value> (*)(v8::Local<v8::String>, v8::Local<v8::Value>);
+ inline void ThrowError(V8ExceptionConstructorOld fun, const char* errmsg);
+ inline void ThrowError(V8ExceptionConstructorNew fun, const char* errmsg);
void TrackContext(v8::Local<v8::Context> context);
void UntrackContext(v8::Local<v8::Context> context);
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 92f765eb0a99f92eac3ce77011e0ec787ccfcb8d..7e77c4692b4d9c4c5daa6ba01878a2219646eb62 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -925,11 +925,8 @@ napi_define_class(napi_env env,
env, p->setter, p->data, &setter_tpl));
}
- tpl->PrototypeTemplate()->SetAccessorProperty(property_name,
- getter_tpl,
- setter_tpl,
- attributes,
- v8::AccessControl::DEFAULT);
+ tpl->PrototypeTemplate()->SetAccessorProperty(
+ property_name, getter_tpl, setter_tpl, attributes);
} else if (p->method != nullptr) {
v8::Local<v8::FunctionTemplate> t;
STATUS_CALL(v8impl::FunctionCallbackWrapper::NewTemplate(
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 77386bd234d0b49b122f1de3d27b1a92da5d0ea4..6861c28eb6deea72e844b04048d88ca726385c7f 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -693,37 +693,38 @@ void BuiltinLoader::CreatePerIsolateProperties(IsolateData* isolate_data,
Local<ObjectTemplate> target) {
Isolate* isolate = isolate_data->isolate();
- target->SetAccessor(isolate_data->config_string(),
- ConfigStringGetter,
- nullptr,
- Local<Value>(),
- DEFAULT,
- None,
- SideEffectType::kHasNoSideEffect);
-
- target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"),
- BuiltinIdsGetter,
- nullptr,
- Local<Value>(),
- DEFAULT,
- None,
- SideEffectType::kHasNoSideEffect);
-
- target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"),
- GetBuiltinCategories,
- nullptr,
- Local<Value>(),
- DEFAULT,
- None,
- SideEffectType::kHasNoSideEffect);
-
- target->SetAccessor(FIXED_ONE_BYTE_STRING(isolate, "natives"),
- GetNatives,
- nullptr,
- Local<Value>(),
- DEFAULT,
- None,
- SideEffectType::kHasNoSideEffect);
+ target->SetNativeDataProperty(isolate_data->config_string(),
+ ConfigStringGetter,
+ nullptr,
+ Local<Value>(),
+ None,
+ DEFAULT,
+ SideEffectType::kHasNoSideEffect);
+
+ target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate, "builtinIds"),
+ BuiltinIdsGetter,
+ nullptr,
+ Local<Value>(),
+ None,
+ DEFAULT,
+ SideEffectType::kHasNoSideEffect);
+
+ target->SetNativeDataProperty(
+ FIXED_ONE_BYTE_STRING(isolate, "builtinCategories"),
+ GetBuiltinCategories,
+ nullptr,
+ Local<Value>(),
+ None,
+ DEFAULT,
+ SideEffectType::kHasNoSideEffect);
+
+ target->SetNativeDataProperty(FIXED_ONE_BYTE_STRING(isolate, "natives"),
+ GetNatives,
+ nullptr,
+ Local<Value>(),
+ None,
+ DEFAULT,
+ SideEffectType::kHasNoSideEffect);
SetMethod(isolate, target, "getCacheUsage", BuiltinLoader::GetCacheUsage);
SetMethod(isolate, target, "compileFunction", BuiltinLoader::CompileFunction);

Просмотреть файл

@ -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 7ef6d04794c31064c70dbbb0bfc1dd7bf4d1b8fc..d5a03d5e10faaa204b3f9f290fed79be824c78b1 100644
index 035f495687856b0cfbcc4e87ba6e90d56c99e837..c02906eacd90ac27d618e7578d1f928f16a858f7 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -87,6 +87,14 @@ MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
@@ -101,6 +101,14 @@ MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
return result;
}
@ -26,10 +26,10 @@ index 7ef6d04794c31064c70dbbb0bfc1dd7bf4d1b8fc..d5a03d5e10faaa204b3f9f290fed79be
void* ret;
if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers)
diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
index 2302e3bad99625eb5dd5587218d0a1985837fb8e..1aa2aafafdae1d2a1b2c851db59e3d736fb8bd3e 100644
index 3034b114e081e2b32dd5b71653927a41af7d48df..49b0175c219d75dd3a038687f353b2428fbdf62b 100644
--- a/src/crypto/crypto_util.cc
+++ b/src/crypto/crypto_util.cc
@@ -349,10 +349,35 @@ ByteSource& ByteSource::operator=(ByteSource&& other) noexcept {
@@ -348,10 +348,35 @@ ByteSource& ByteSource::operator=(ByteSource&& other) noexcept {
return *this;
}
@ -66,7 +66,7 @@ index 2302e3bad99625eb5dd5587218d0a1985837fb8e..1aa2aafafdae1d2a1b2c851db59e3d73
std::unique_ptr<BackingStore> ptr = ArrayBuffer::NewBackingStore(
allocated_data_,
size(),
@@ -364,10 +389,11 @@ std::unique_ptr<BackingStore> ByteSource::ReleaseToBackingStore() {
@@ -363,10 +388,11 @@ std::unique_ptr<BackingStore> ByteSource::ReleaseToBackingStore() {
data_ = nullptr;
size_ = 0;
return ptr;
@ -79,7 +79,7 @@ index 2302e3bad99625eb5dd5587218d0a1985837fb8e..1aa2aafafdae1d2a1b2c851db59e3d73
return ArrayBuffer::New(env->isolate(), std::move(store));
}
@@ -696,6 +722,16 @@ namespace {
@@ -702,6 +728,16 @@ namespace {
// in which case this has the same semantics as
// using OPENSSL_malloc. However, if the secure heap is
// initialized, SecureBuffer will automatically use it.
@ -96,7 +96,7 @@ index 2302e3bad99625eb5dd5587218d0a1985837fb8e..1aa2aafafdae1d2a1b2c851db59e3d73
void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsUint32());
Environment* env = Environment::GetCurrent(args);
@@ -717,6 +753,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
@@ -723,6 +759,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
Local<ArrayBuffer> buffer = ArrayBuffer::New(env->isolate(), store);
args.GetReturnValue().Set(Uint8Array::New(buffer, 0, len));
}
@ -105,7 +105,7 @@ index 2302e3bad99625eb5dd5587218d0a1985837fb8e..1aa2aafafdae1d2a1b2c851db59e3d73
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 bf19334cf61fa497c9325c1d2e996a16545f1b7f..333039b3b7cdf29e911a9c09932b2588d4cccf1a 100644
index 1ce5f35a70a7c855796cc96d4201cc996907cf8f..be700c953d55b35bd2fee7fd872efd9ed2600c63 100644
--- a/src/crypto/crypto_util.h
+++ b/src/crypto/crypto_util.h
@@ -280,7 +280,7 @@ class ByteSource {
@ -118,10 +118,10 @@ index bf19334cf61fa497c9325c1d2e996a16545f1b7f..333039b3b7cdf29e911a9c09932b2588
v8::Local<v8::ArrayBuffer> ToArrayBuffer(Environment* env);
diff --git a/src/node_i18n.cc b/src/node_i18n.cc
index bb810632ee6617759d9cbd24c84a5d1a3a6081aa..3faf9840eddf2db993baef0866bc8854b49c0700 100644
index d45325954d980724f80d49298bbe837197237a9b..ccea18080142bd9cba3765dbbec61c2a63406667 100644
--- a/src/node_i18n.cc
+++ b/src/node_i18n.cc
@@ -104,7 +104,7 @@ namespace {
@@ -105,7 +105,7 @@ namespace {
template <typename T>
MaybeLocal<Object> ToBufferEndian(Environment* env, MaybeStackBuffer<T>* buf) {
@ -131,7 +131,7 @@ index bb810632ee6617759d9cbd24c84a5d1a3a6081aa..3faf9840eddf2db993baef0866bc8854
return ret;
diff --git a/src/node_internals.h b/src/node_internals.h
index 427cfab4eebcab0aed33e42915f4a0e5a9db7cdf..d174b2720b0b2561ebe30437df609e0366388527 100644
index d7f78664615fcfca6ed7404f940906c148a5e02c..35d76aaa69abfaca18421f12aa1ff78297b8f93f 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -102,7 +102,9 @@ v8::Maybe<bool> InitializePrimordials(v8::Local<v8::Context> context);
@ -155,7 +155,7 @@ index 427cfab4eebcab0aed33e42915f4a0e5a9db7cdf..d174b2720b0b2561ebe30437df609e03
// Delegate to V8's allocator for compatibility with the V8 memory cage.
diff --git a/src/node_serdes.cc b/src/node_serdes.cc
index 6864f2d88b34abfa4090780d6993684cd0b366a3..0249574c4431fb5b98852699f1368f71b49691c1 100644
index 6698a1df81cb4e0947c86fb30c2d77fca8e2d9d1..dad297652b347819805b09fbfd869f1d037e31c1 100644
--- a/src/node_serdes.cc
+++ b/src/node_serdes.cc
@@ -29,6 +29,11 @@ using v8::ValueSerializer;
@ -237,14 +237,3 @@ index 6864f2d88b34abfa4090780d6993684cd0b366a3..0249574c4431fb5b98852699f1368f71
if (!buf.IsEmpty()) {
args.GetReturnValue().Set(buf.ToLocalChecked());
diff --git a/test/parallel/test-v8-serialize-leak.js b/test/parallel/test-v8-serialize-leak.js
index 696dbfea65ba95b1157cb6f469762d4a6e196199..b342ec59100809187689d0770a462b0b99e75e58 100644
--- a/test/parallel/test-v8-serialize-leak.js
+++ b/test/parallel/test-v8-serialize-leak.js
@@ -25,5 +25,5 @@ if (process.config.variables.asan) {
} else if (process.config.variables.node_builtin_modules_path) {
assert(after < before * 4, `node_builtin_modules_path: before=${before} after=${after}`);
} else {
- assert(after < before * 2, `before=${before} after=${after}`);
+ assert(after < before * 3, `before=${before} after=${after}`);
}

Просмотреть файл

@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luigi Pinca <luigipinca@gmail.com>
Date: Wed, 13 Sep 2023 08:04:39 +0200
Subject: test: deflake test-tls-socket-close
Move the check for the destroyed state of the remote socket to the inner
`setImmediate()`.
Refs: https://github.com/nodejs/node/pull/49327#issuecomment-1712525257
PR-URL: https://github.com/nodejs/node/pull/49575
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
diff --git a/test/parallel/test-tls-socket-close.js b/test/parallel/test-tls-socket-close.js
index 667b291309a4c5636a2c658fa8204b32c2e4df46..70af760d53bb4ddab62c99180d505e943ec269f6 100644
--- a/test/parallel/test-tls-socket-close.js
+++ b/test/parallel/test-tls-socket-close.js
@@ -44,9 +44,9 @@ function connectClient(server) {
setImmediate(() => {
assert.strictEqual(netSocket.destroyed, true);
- assert.strictEqual(clientTlsSocket.destroyed, true);
setImmediate(() => {
+ assert.strictEqual(clientTlsSocket.destroyed, true);
assert.strictEqual(serverTlsSocket.destroyed, true);
tlsServer.close();

Просмотреть файл

@ -6,11 +6,11 @@ Subject: test: fix edge snapshot stack traces
https://github.com/nodejs/node/pull/49659
diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js
index 83ee45f5f906adddcbc701112f373332dd1f66f9..7b6a9d59bfaa0247f4466277097cd5575ff81d0c 100644
index 838ee86f74ea89e052676a5c25e23481369857fa..3aacfa064561c64c218fcc4e3090f7952cb1d218 100644
--- a/test/common/assertSnapshot.js
+++ b/test/common/assertSnapshot.js
@@ -8,6 +8,10 @@ const assert = require('node:assert/strict');
const stackFramesRegexp = /(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
const windowNewlineRegexp = /\r/g;
+function replaceNodeVersion(str) {
@ -20,27 +20,27 @@ index 83ee45f5f906adddcbc701112f373332dd1f66f9..7b6a9d59bfaa0247f4466277097cd557
function replaceStackTrace(str, replacement = '$1*$7$8\n') {
return str.replace(stackFramesRegexp, replacement);
}
@@ -70,6 +74,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
@@ -84,6 +88,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
module.exports = {
assertSnapshot,
getSnapshotPath,
+ replaceNodeVersion,
replaceFullPaths,
replaceStackTrace,
replaceWindowsLineEndings,
replaceWindowsPaths,
diff --git a/test/fixtures/errors/force_colors.snapshot b/test/fixtures/errors/force_colors.snapshot
index 4c33acbc2d5c12ac8750b72e0796284176af3da2..21410d492db861876ecfcb82dcc3c1815cba6d09 100644
index be1d45d0d8e8ba7b637754e32fe379cb2cf1e6ac..21410d492db861876ecfcb82dcc3c1815cba6d09 100644
--- a/test/fixtures/errors/force_colors.snapshot
+++ b/test/fixtures/errors/force_colors.snapshot
@@ -4,11 +4,12 @@ throw new Error('Should include grayed stack trace')
Error: Should include grayed stack trace
at Object.<anonymous> (/test*force_colors.js:1:7)
- at Module._compile (node:internal*modules*cjs*loader:1256:14)
- at Module._extensions..js (node:internal*modules*cjs*loader:1310:10)
- at Module.load (node:internal*modules*cjs*loader:1119:32)
- at Module._load (node:internal*modules*cjs*loader:960:12)
- at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:86:12)
- at Module._compile (node:internal*modules*cjs*loader:1241:14)
- at Module._extensions..js (node:internal*modules*cjs*loader:1295:10)
- at Module.load (node:internal*modules*cjs*loader:1091:32)
- at Module._load (node:internal*modules*cjs*loader:938:12)
- at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12)
- at node:internal*main*run_main_module:23:47
+ at *
+ at *
@ -51,14 +51,24 @@ index 4c33acbc2d5c12ac8750b72e0796284176af3da2..21410d492db861876ecfcb82dcc3c181
+ at *
Node.js *
diff --git a/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
index 2c1e11eeb9eab1bcb101f8f5af909461b26036ec..6a109c904e115503b743d5c4e0418ae693ca9856 100644
--- a/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
+++ b/test/fixtures/source-map/output/source_map_sourcemapping_url_string.snapshot
@@ -1,3 +1,3 @@
Error: an exception.
at Object.<anonymous> (*typescript-sourcemapping_url_string.ts:3:7)
- at Module._compile (node:internal*modules*cjs*loader:1241:14)
+ *
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
index b9a55fb7ea22e62553f69bd035797f7aaee1fc38..1f5ce52cf674cfc5fb75ad2cd979752a991c7e28 100644
index b08bcd40cdf26093e158c0bb9ae566c76f2c731e..bf8eacbac479a2bf5698ed29ede648e149f185b5 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -10,14 +10,15 @@ const skipForceColors =
@@ -10,15 +10,15 @@ const skipForceColors =
process.config.variables.node_shared_openssl ||
(common.isWindows && (Number(os.release().split('.')[0]) !== 10 || Number(os.release().split('.')[2]) < 14393)); // See https://github.com/nodejs/node/pull/33132
-
-function replaceNodeVersion(str) {
- return str.replaceAll(process.version, '*');
-}
@ -74,8 +84,8 @@ index b9a55fb7ea22e62553f69bd035797f7aaee1fc38..1f5ce52cf674cfc5fb75ad2cd979752a
+
describe('errors output', { concurrency: true }, () => {
function normalize(str) {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*errors*', '*').replaceAll('file:**', 'file:*/');
@@ -28,9 +29,12 @@ describe('errors output', { concurrency: true }, () => {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
@@ -35,9 +35,12 @@ describe('errors output', { concurrency: true }, () => {
}
const common = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths);
@ -91,21 +101,21 @@ index b9a55fb7ea22e62553f69bd035797f7aaee1fc38..1f5ce52cf674cfc5fb75ad2cd979752a
const tests = [
{ name: 'errors/async_error_eval_cjs.js' },
@@ -50,7 +54,11 @@ describe('errors output', { concurrency: true }, () => {
@@ -57,7 +60,11 @@ describe('errors output', { concurrency: true }, () => {
{ name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
{ name: 'errors/throw_non_error.js', transform: errTransform },
{ name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
- !skipForceColors ? { name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } } : null,
- { skip: skipForceColors, name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } },
+ !skipForceColors ? {
+ name: 'errors/force_colors.js',
+ transform: forceColorsTransform,
+ env: { FORCE_COLOR: 1 }
+ } : null,
].filter(Boolean);
for (const { name, transform, env } of tests) {
if (env) env.ELECTRON_RUN_AS_NODE = 1;
];
for (const { name, transform = defaultTransform, env, skip = false } of tests) {
it(name, { skip }, async () => {
diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs
index 8e43947ab2188f087056eab39d0e1a11481f9da5..c53a0598958e4e386db1993caeb312dae3f302a8 100644
index 2043fa57f06a8d2326a4ea1ba24341502c8b7471..b01f30765c7de81a4d956b9c1124affea0fc2aef 100644
--- a/test/parallel/test-node-output-sourcemaps.mjs
+++ b/test/parallel/test-node-output-sourcemaps.mjs
@@ -4,10 +4,6 @@ import * as snapshot from '../common/assertSnapshot.js';

Просмотреть файл

@ -7,13 +7,13 @@ 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 8de4ad29cb14149ed0c15eb201b3d17be506bac9..182aab4bc781da4c1968a84f87c1e7f2f0b986f1 100644
index fe8ddee7cbf05e0d4dbbe970cdc357ec6841390c..1ba65e26d293e9524e6c756b3a66693d46b4bdfd 100644
--- a/test/parallel/parallel.status
+++ b/test/parallel/parallel.status
@@ -5,6 +5,13 @@ prefix parallel
# sample-test : PASS,FLAKY
@@ -7,6 +7,13 @@ prefix parallel
[true] # This section applies to all platforms
# https://github.com/nodejs/node/issues/49853
test-runner-output: PASS,FLAKY
+test-inspector-multisession-ws: PASS, FLAKY
+test-heapsnapshot-near-heap-limit-by-api-in-worker: PASS, FLAKY
+test-heapsnapshot-near-heap-limit-worker: PASS, FLAKY
@ -25,7 +25,7 @@ index 8de4ad29cb14149ed0c15eb201b3d17be506bac9..182aab4bc781da4c1968a84f87c1e7f2
[$system==win32]
# https://github.com/nodejs/node/issues/41206
diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status
index 0688f5b05e789c15f2c9fc4c9e1a20cd5d1ba8be..64dc814fd24f3e6d90f246a4e66531696eab03cd 100644
index 5cefcb95773bedc80bc462e058a11045be176741..33f50be5898754af696468499bcfa8e3c721434d 100644
--- a/test/sequential/sequential.status
+++ b/test/sequential/sequential.status
@@ -7,6 +7,18 @@ prefix sequential

Просмотреть файл

@ -1,204 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tim Perry <1526883+pimterry@users.noreply.github.com>
Date: Fri, 1 Sep 2023 09:00:05 +0200
Subject: tls: ensure TLS Sockets are closed if the underlying wrap closes
This fixes a potential segfault, among various other likely-related
issues, which all occur because TLSSockets were not informed if their
underlying stream was closed in many cases.
This also significantly modifies an existing TLS test. With this change
in place, that test no longer works, as it tries to mess with internals
to trigger a race, and those internals are now cleaned up earlier. This
test has been simplified to a more general TLS shutdown test.
PR-URL: https://github.com/nodejs/node/pull/49327
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index 84599102be4b74ff66af63c36c232f4656a1f406..bb0535558a8999034a99d0e7e99507ba10eca2eb 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -661,6 +661,9 @@ TLSSocket.prototype._wrapHandle = function(wrap, handle, wrapHasActiveWriteFromP
defineHandleReading(this, handle);
this.on('close', onSocketCloseDestroySSL);
+ if (wrap) {
+ wrap.on('close', () => this.destroy());
+ }
return res;
};
diff --git a/test/parallel/test-http2-socket-close.js b/test/parallel/test-http2-socket-close.js
new file mode 100644
index 0000000000000000000000000000000000000000..02db77bcf8480c79c77175ba802f9fe10ffc4efe
--- /dev/null
+++ b/test/parallel/test-http2-socket-close.js
@@ -0,0 +1,67 @@
+'use strict';
+
+const common = require('../common');
+const fixtures = require('../common/fixtures');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+const assert = require('assert');
+const net = require('net');
+const h2 = require('http2');
+
+const tlsOptions = {
+ key: fixtures.readKey('agent1-key.pem'),
+ cert: fixtures.readKey('agent1-cert.pem'),
+ ALPNProtocols: ['h2']
+};
+
+// Create a net server that upgrades sockets to HTTP/2 manually, handles the
+// request, and then shuts down via a short socket timeout and a longer H2 session
+// timeout. This is an unconventional way to shut down a session (the underlying
+// socket closing first) but it should work - critically, it shouldn't segfault
+// (as it did until Node v20.5.1).
+
+let serverRawSocket;
+let serverH2Session;
+
+const netServer = net.createServer((socket) => {
+ serverRawSocket = socket;
+ h2Server.emit('connection', socket);
+});
+
+const h2Server = h2.createSecureServer(tlsOptions, (req, res) => {
+ res.writeHead(200);
+ res.end();
+});
+
+h2Server.on('session', (session) => {
+ serverH2Session = session;
+});
+
+netServer.listen(0, common.mustCall(() => {
+ const proxyClient = h2.connect(`https://localhost:${netServer.address().port}`, {
+ rejectUnauthorized: false
+ });
+
+ proxyClient.on('close', common.mustCall(() => {
+ netServer.close();
+ }));
+
+ const req = proxyClient.request({
+ ':method': 'GET',
+ ':path': '/'
+ });
+
+ req.on('response', common.mustCall((response) => {
+ assert.strictEqual(response[':status'], 200);
+
+ // Asynchronously shut down the server's connections after the response,
+ // but not in the order it typically expects:
+ setTimeout(() => {
+ serverRawSocket.destroy();
+
+ setTimeout(() => {
+ serverH2Session.close();
+ }, 10);
+ }, 10);
+ }));
+}));
diff --git a/test/parallel/test-tls-socket-close.js b/test/parallel/test-tls-socket-close.js
index 87355cf8d7bd2d07bb0fab59491b68f3963f8809..667b291309a4c5636a2c658fa8204b32c2e4df46 100644
--- a/test/parallel/test-tls-socket-close.js
+++ b/test/parallel/test-tls-socket-close.js
@@ -8,37 +8,18 @@ const tls = require('tls');
const net = require('net');
const fixtures = require('../common/fixtures');
-// Regression test for https://github.com/nodejs/node/issues/8074
-//
-// This test has a dependency on the order in which the TCP connection is made,
-// and TLS server handshake completes. It assumes those server side events occur
-// before the client side write callback, which is not guaranteed by the TLS
-// API. It usually passes with TLS1.3, but TLS1.3 didn't exist at the time the
-// bug existed.
-//
-// Pin the test to TLS1.2, since the test shouldn't be changed in a way that
-// doesn't trigger a segfault in Node.js 7.7.3:
-// https://github.com/nodejs/node/issues/13184#issuecomment-303700377
-tls.DEFAULT_MAX_VERSION = 'TLSv1.2';
-
const key = fixtures.readKey('agent2-key.pem');
const cert = fixtures.readKey('agent2-cert.pem');
-let tlsSocket;
-// tls server
+let serverTlsSocket;
const tlsServer = tls.createServer({ cert, key }, (socket) => {
- tlsSocket = socket;
- socket.on('error', common.mustCall((error) => {
- assert.strictEqual(error.code, 'EINVAL');
- tlsServer.close();
- netServer.close();
- }));
+ serverTlsSocket = socket;
});
+// A plain net server, that manually passes connections to the TLS
+// server to be upgraded
let netSocket;
-// plain tcp server
const netServer = net.createServer((socket) => {
- // If client wants to use tls
tlsServer.emit('connection', socket);
netSocket = socket;
@@ -46,35 +27,32 @@ const netServer = net.createServer((socket) => {
connectClient(netServer);
}));
+// A client that connects, sends one message, and closes the raw connection:
function connectClient(server) {
- const tlsConnection = tls.connect({
+ const clientTlsSocket = tls.connect({
host: 'localhost',
port: server.address().port,
rejectUnauthorized: false
});
- tlsConnection.write('foo', 'utf8', common.mustCall(() => {
+ clientTlsSocket.write('foo', 'utf8', common.mustCall(() => {
assert(netSocket);
netSocket.setTimeout(common.platformTimeout(10), common.mustCall(() => {
- assert(tlsSocket);
- // This breaks if TLSSocket is already managing the socket:
+ assert(serverTlsSocket);
+
netSocket.destroy();
- const interval = setInterval(() => {
- // Checking this way allows us to do the write at a time that causes a
- // segmentation fault (not always, but often) in Node.js 7.7.3 and
- // earlier. If we instead, for example, wait on the `close` event, then
- // it will not segmentation fault, which is what this test is all about.
- if (tlsSocket._handle._parent.bytesRead === 0) {
- tlsSocket.write('bar');
- clearInterval(interval);
- }
- }, 1);
+
+ setImmediate(() => {
+ assert.strictEqual(netSocket.destroyed, true);
+ assert.strictEqual(clientTlsSocket.destroyed, true);
+
+ setImmediate(() => {
+ assert.strictEqual(serverTlsSocket.destroyed, true);
+
+ tlsServer.close();
+ netServer.close();
+ });
+ });
}));
}));
- tlsConnection.on('error', (e) => {
- // Tolerate the occasional ECONNRESET.
- // Ref: https://github.com/nodejs/node/issues/13184
- if (e.code !== 'ECONNRESET')
- throw e;
- });
}

Просмотреть файл

@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Fri, 26 Aug 2022 00:03:44 +0900
Subject: v8: [api] Advance API deprecation
Refs https://chromium-review.googlesource.com/c/v8/v8/+/3702449
This can be removed when Electron upgrades to Node.js v20.
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index 4c9f7f636aeeb19a87150ac5a05e28159503f051..6f3821247f7a1b9e4615c2f21d4098114e64d798 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -219,7 +219,8 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
bool prevent_shutdown)
: delegate_(std::move(delegate)), prevent_shutdown_(prevent_shutdown),
retaining_context_(false) {
- session_ = inspector->connect(CONTEXT_GROUP_ID, this, StringView());
+ session_ = inspector->connect(
+ CONTEXT_GROUP_ID, this, StringView(),V8Inspector::kFullyTrusted);
node_dispatcher_ = std::make_unique<protocol::UberDispatcher>(this);
tracing_agent_ =
std::make_unique<protocol::TracingAgent>(env, main_thread_);

Просмотреть файл

@ -18,10 +18,10 @@ as launch more jobs or exit).
Fixes: https://github.com/JuliaLang/julia/issues/51461
diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c
index 24c633393fd15dcf87726b174d6b027a969e0f0d..4ad9fec900fa66b0e8c6894701e94f420de903a8 100644
index 3e451e2291d6ed200ec258e874becbbea22bbc27..a71a08bdd60166ef1d4ef490ff3e083b44188852 100644
--- a/deps/uv/src/win/process.c
+++ b/deps/uv/src/win/process.c
@@ -102,6 +102,21 @@ static void uv__init_global_job_handle(void) {
@@ -105,6 +105,21 @@ static void uv__init_global_job_handle(void) {
&info,
sizeof info))
uv_fatal_error(GetLastError(), "SetInformationJobObject");
@ -43,7 +43,7 @@ index 24c633393fd15dcf87726b174d6b027a969e0f0d..4ad9fec900fa66b0e8c6894701e94f42
}
@@ -1098,6 +1113,7 @@ int uv_spawn(uv_loop_t* loop,
@@ -1102,6 +1117,7 @@ int uv_spawn(uv_loop_t* loop,
* breakaway.
*/
process_flags |= DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP;
@ -51,7 +51,7 @@ index 24c633393fd15dcf87726b174d6b027a969e0f0d..4ad9fec900fa66b0e8c6894701e94f42
}
if (!CreateProcessW(application_path,
@@ -1115,11 +1131,6 @@ int uv_spawn(uv_loop_t* loop,
@@ -1119,11 +1135,6 @@ int uv_spawn(uv_loop_t* loop,
goto done;
}
@ -63,7 +63,7 @@ index 24c633393fd15dcf87726b174d6b027a969e0f0d..4ad9fec900fa66b0e8c6894701e94f42
/* If the process isn't spawned as detached, assign to the global job object
* so windows will kill it when the parent process dies. */
if (!(options->flags & UV_PROCESS_DETACHED)) {
@@ -1142,6 +1153,19 @@ int uv_spawn(uv_loop_t* loop,
@@ -1146,6 +1157,19 @@ int uv_spawn(uv_loop_t* loop,
}
}

Просмотреть файл

@ -1,3 +1,4 @@
chore_allow_customizing_microtask_policy_per_context.patch
build_expose_mksnapshot_to_embedders.patch
build_correctly_expose_public_symbols_with_v8_expose_public_symbols.patch
deps_add_v8_object_setinternalfieldfornodecore.patch

Просмотреть файл

@ -0,0 +1,87 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 14 Nov 2023 17:48:11 +0100
Subject: deps: add v8::Object::SetInternalFieldForNodeCore()
This is a non-ABI breaking solution added by Node.js in v20.x for:
* https://chromium-review.googlesource.com/c/v8/v8/+/4827307
* https://chromium-review.googlesource.com/c/v8/v8/+/4707972
which are necessary for backporting the vm-related memory fixes in https://github.com/nodejs/node/pull/48510.
diff --git a/include/v8-object.h b/include/v8-object.h
index 6cdf53b19c7d058bb66b9fcbe745874cc48daa99..8d112008c2667db97ed5b5af3f87c40d0ef8466a 100644
--- a/include/v8-object.h
+++ b/include/v8-object.h
@@ -20,6 +20,8 @@ class Function;
class FunctionTemplate;
template <typename T>
class PropertyCallbackInfo;
+class Module;
+class UnboundScript;
/**
* A private symbol
@@ -509,6 +511,21 @@ class V8_EXPORT Object : public Value {
index);
}
+ /**
+ * Warning: These are Node.js-specific extentions used to avoid breaking
+ * changes in Node.js v20.x. They do not exist in V8 upstream and will
+ * not exist in Node.js v21.x. Node.js embedders and addon authors should
+ * not use them from v20.x.
+ */
+#ifndef NODE_WANT_INTERNALS
+ V8_DEPRECATED("This extention should only be used by Node.js core")
+#endif
+ void SetInternalFieldForNodeCore(int index, Local<Module> value);
+#ifndef NODE_WANT_INTERNALS
+ V8_DEPRECATED("This extention should only be used by Node.js core")
+#endif
+ void SetInternalFieldForNodeCore(int index, Local<UnboundScript> value);
+
/** Same as above, but works for TracedReference. */
V8_INLINE static void* GetAlignedPointerFromInternalField(
const BasicTracedReference<Object>& object, int index) {
diff --git a/src/api/api.cc b/src/api/api.cc
index 694aec891a48337fa0387d60bcc34e05752ff2f0..a4931493e9d1a5cb0d5aded2611729f630819dc5 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -6318,14 +6318,33 @@ Local<Data> v8::Object::SlowGetInternalField(int index) {
isolate);
}
-void v8::Object::SetInternalField(int index, v8::Local<Data> value) {
- auto obj = Utils::OpenDirectHandle(this);
+template<typename T>
+void SetInternalFieldImpl(v8::Object* receiver, int index, v8::Local<T> value) {
+ auto obj = Utils::OpenDirectHandle(receiver);
const char* location = "v8::Object::SetInternalField()";
if (!InternalFieldOK(obj, index, location)) return;
auto val = Utils::OpenDirectHandle(*value);
i::DirectHandle<i::JSObject>::cast(obj)->SetEmbedderField(index, *val);
}
+void v8::Object::SetInternalField(int index, v8::Local<Data> value) {
+ SetInternalFieldImpl(this, index, value);
+}
+
+/**
+ * These are Node.js-specific extentions used to avoid breaking changes in
+ * Node.js v20.x.
+ */
+void v8::Object::SetInternalFieldForNodeCore(int index,
+ v8::Local<Module> value) {
+ SetInternalFieldImpl(this, index, value);
+}
+
+void v8::Object::SetInternalFieldForNodeCore(int index,
+ v8::Local<UnboundScript> value) {
+ SetInternalFieldImpl(this, index, value);
+}
+
void* v8::Object::SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate,
int index) {
auto obj = Utils::OpenDirectHandle(this);

Просмотреть файл

@ -6,6 +6,7 @@
"parallel/test-crypto-aes-wrap",
"parallel/test-crypto-authenticated-stream",
"parallel/test-crypto-des3-wrap",
"parallel/test-crypto-dh-group-setters",
"parallel/test-crypto-dh-modp2",
"parallel/test-crypto-dh-modp2-views",
"parallel/test-crypto-dh-stateless",
@ -20,6 +21,9 @@
"parallel/test-dgram-send-cb-quelches-error",
"parallel/test-fs-utimes-y2K38",
"parallel/test-http2-clean-output",
"parallel/test-http2-https-fallback.js",
"parallel/test-http2-server-unknown-protocol.js",
"parallel/test-tls-alpn-server-client.js",
"parallel/test-https-agent-session-reuse",
"parallel/test-https-options-boolean-check",
"parallel/test-icu-env",
@ -31,11 +35,13 @@
"parallel/test-process-versions",
"parallel/test-repl",
"parallel/test-repl-underscore",
"parallel/test-single-executable-application",
"parallel/test-single-executable-blob-config",
"parallel/test-single-executable-blob-config-errors",
"parallel/test-snapshot-api",
"parallel/test-snapshot-argv1",
"parallel/test-snapshot-basic",
"parallel/test-snapshot-cjs-main",
"parallel/test-snapshot-cwd",
"parallel/test-snapshot-console",
"parallel/test-snapshot-dns-lookup-localhost",
"parallel/test-snapshot-dns-lookup-localhost-promise",
@ -46,10 +52,12 @@
"parallel/test-snapshot-gzip",
"parallel/test-snapshot-incompatible",
"parallel/test-snapshot-namespaced-builtin",
"parallel/test-snapshot-net",
"parallel/test-snapshot-typescript",
"parallel/test-snapshot-umd",
"parallel/test-snapshot-warning",
"parallel/test-snapshot-weak-reference",
"parallel/test-snapshot-worker",
"parallel/test-strace-openat-openssl",
"parallel/test-tls-cert-chains-concat",
"parallel/test-tls-cert-chains-in-ca",
@ -143,6 +151,12 @@
"report/test-report-uv-handles",
"report/test-report-worker",
"report/test-report-writereport",
"sequential/test-single-executable-application",
"sequential/test-single-executable-application-disable-experimental-sea-warning",
"sequential/test-single-executable-application-empty",
"sequential/test-single-executable-application-snapshot",
"sequential/test-single-executable-application-snapshot-and-code-cache",
"sequential/test-single-executable-application-use-code-cache",
"sequential/test-tls-connect",
"wpt/test-webcrypto"
]

Просмотреть файл

@ -199,9 +199,9 @@ static void InitAsarSupport(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::vector<v8::Local<v8::String>> asar_bundle_params = {
node::FIXED_ONE_BYTE_STRING(isolate, "require")};
std::vector<v8::Local<v8::Value>> asar_bundle_args = {require};
electron::util::CompileAndCall(
isolate->GetCurrentContext(), "electron/js2c/asar_bundle",
&asar_bundle_params, &asar_bundle_args, nullptr);
electron::util::CompileAndCall(isolate->GetCurrentContext(),
"electron/js2c/asar_bundle",
&asar_bundle_params, &asar_bundle_args);
}
static void SplitPath(const v8::FunctionCallbackInfo<v8::Value>& args) {

Просмотреть файл

@ -513,26 +513,35 @@ void NodeBindings::Initialize(v8::Local<v8::Context> context) {
SetNodeOptions(env.get());
// Parse and set Node.js cli flags.
std::vector<std::string> argv = ParseNodeCliFlags();
std::vector<std::string> exec_argv;
std::vector<std::string> errors;
uint64_t process_flags = node::ProcessFlags::kNoFlags;
std::vector<std::string> args = ParseNodeCliFlags();
uint64_t process_flags =
node::ProcessInitializationFlags::kNoInitializeV8 |
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform |
node::ProcessInitializationFlags::kNoEnableWasmTrapHandler;
// We do not want the child processes spawned from the utility process
// to inherit the custom stdio handles created for the parent.
if (browser_env_ != BrowserEnvironment::kUtility)
process_flags |= node::ProcessFlags::kEnableStdioInheritance;
process_flags |= node::ProcessInitializationFlags::kEnableStdioInheritance;
if (browser_env_ == BrowserEnvironment::kRenderer)
process_flags |= node::ProcessInitializationFlags::kNoInitializeCppgc |
node::ProcessInitializationFlags::kNoDefaultSignalHandling;
if (!fuses::IsNodeOptionsEnabled())
process_flags |= node::ProcessFlags::kDisableNodeOptionsEnv;
process_flags |= node::ProcessInitializationFlags::kDisableNodeOptionsEnv;
int exit_code = node::InitializeNodeWithArgs(
&argv, &exec_argv, &errors,
static_cast<node::ProcessFlags::Flags>(process_flags));
std::unique_ptr<node::InitializationResult> result =
node::InitializeOncePerProcess(
args,
static_cast<node::ProcessInitializationFlags::Flags>(process_flags));
for (const std::string& error : errors)
fprintf(stderr, "%s: %s\n", argv[0].c_str(), error.c_str());
for (const std::string& error : result->errors()) {
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
}
if (exit_code != 0)
exit(exit_code);
if (result->early_return() != 0)
exit(result->exit_code());
#if BUILDFLAG(IS_WIN)
// uv_init overrides error mode to suppress the default crash dialog, bring
@ -605,10 +614,10 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment(
static_cast<void*>(isolate_data));
node::Environment* env;
uint64_t flags = node::EnvironmentFlags::kDefaultFlags |
node::EnvironmentFlags::kHideConsoleWindows |
node::EnvironmentFlags::kNoGlobalSearchPaths |
node::EnvironmentFlags::kNoRegisterESMLoader;
uint64_t env_flags = node::EnvironmentFlags::kDefaultFlags |
node::EnvironmentFlags::kHideConsoleWindows |
node::EnvironmentFlags::kNoGlobalSearchPaths |
node::EnvironmentFlags::kNoRegisterESMLoader;
if (browser_env_ == BrowserEnvironment::kRenderer ||
browser_env_ == BrowserEnvironment::kWorker) {
@ -620,21 +629,21 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment(
// for processes that already have these defined by DOM.
// Check //third_party/electron_node/lib/internal/bootstrap/node.js
// for the list of overrides on globalThis.
flags |= node::EnvironmentFlags::kNoBrowserGlobals |
node::EnvironmentFlags::kNoCreateInspector;
env_flags |= node::EnvironmentFlags::kNoBrowserGlobals |
node::EnvironmentFlags::kNoCreateInspector;
}
if (!electron::fuses::IsNodeCliInspectEnabled()) {
// If --inspect and friends are disabled we also shouldn't listen for
// SIGUSR1
flags |= node::EnvironmentFlags::kNoStartDebugSignalHandler;
env_flags |= node::EnvironmentFlags::kNoStartDebugSignalHandler;
}
{
v8::TryCatch try_catch(isolate);
env = node::CreateEnvironment(
static_cast<node::IsolateData*>(isolate_data), context, args, exec_args,
static_cast<node::EnvironmentFlags::Flags>(flags));
static_cast<node::EnvironmentFlags::Flags>(env_flags));
if (try_catch.HasCaught()) {
std::string err_msg =

Просмотреть файл

@ -13,19 +13,21 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
v8::Local<v8::Context> context,
const char* id,
std::vector<v8::Local<v8::String>>* parameters,
std::vector<v8::Local<v8::Value>>* arguments,
node::Environment* optional_env) {
std::vector<v8::Local<v8::Value>>* arguments) {
v8::Isolate* isolate = context->GetIsolate();
v8::TryCatch try_catch(isolate);
v8::MaybeLocal<v8::Function> compiled =
node::builtins::BuiltinLoader::LookupAndCompile(context, id, parameters,
optional_env);
if (compiled.IsEmpty()) {
thread_local node::builtins::BuiltinLoader builtin_loader;
v8::MaybeLocal<v8::Function> compiled = builtin_loader.LookupAndCompile(
context, id, parameters, node::Realm::GetCurrent(context));
if (compiled.IsEmpty())
return v8::MaybeLocal<v8::Value>();
}
v8::Local<v8::Function> fn = compiled.ToLocalChecked().As<v8::Function>();
v8::MaybeLocal<v8::Value> ret = fn->Call(
context, v8::Null(isolate), arguments->size(), arguments->data());
// This will only be caught when something has gone terrible wrong as all
// electron scripts are wrapped in a try {} catch {} by webpack
if (try_catch.HasCaught()) {

Просмотреть файл

@ -24,8 +24,7 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
v8::Local<v8::Context> context,
const char* id,
std::vector<v8::Local<v8::String>>* parameters,
std::vector<v8::Local<v8::Value>>* arguments,
node::Environment* optional_env);
std::vector<v8::Local<v8::Value>>* arguments);
} // namespace electron::util

Просмотреть файл

@ -192,7 +192,7 @@ void ElectronSandboxedRendererClient::DidCreateScriptContext(
util::CompileAndCall(
isolate->GetCurrentContext(), "electron/js2c/sandbox_bundle",
&sandbox_preload_bundle_params, &sandbox_preload_bundle_args, nullptr);
&sandbox_preload_bundle_params, &sandbox_preload_bundle_args);
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context);

Просмотреть файл

@ -625,7 +625,7 @@ void RendererClientBase::SetupMainWorldOverrides(
isolated_api.GetHandle()};
util::CompileAndCall(context, "electron/js2c/isolated_bundle",
&isolated_bundle_params, &isolated_bundle_args, nullptr);
&isolated_bundle_params, &isolated_bundle_args);
}
// static

Просмотреть файл

@ -944,10 +944,12 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.13.tgz#7dfd9c14661edc65cccd43a29eb454174642370d"
integrity sha512-bLL69sKtd25w7p1nvg9pigE4gtKVpGTPojBFLMkGHXuUgap2sLqQt2qUnqmVCDfzGUL0DRNZP+1prIZJbMeAXg==
"@types/node@^18.11.18":
version "18.11.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==
"@types/node@^20.9.0":
version "20.9.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.9.0.tgz#bfcdc230583aeb891cf51e73cfdaacdd8deae298"
integrity sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==
dependencies:
undici-types "~5.26.4"
"@types/normalize-package-data@^2.4.0":
version "2.4.1"
@ -6795,6 +6797,11 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"
undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
unified-args@^9.0.0:
version "9.0.2"
resolved "https://registry.yarnpkg.com/unified-args/-/unified-args-9.0.2.tgz#0c14f555e73ee29c23f9a567942e29069f56e5a2"