chore: bump node to v20.10.0 (main) (#40675)

* chore: bump node in DEPS to v20.10.0

* chore: update feat_initialize_asar_support.patch

no code changes; patch just needed an update due to nearby upstream changes

Xref: https://github.com/nodejs/node/pull/49986

* chore: update pass_all_globals_through_require.patch

no manual changes; patch applied with fuzz

Xref: https://github.com/nodejs/node/pull/49657

* chore: update refactor_allow_embedder_overriding_of_internal_fs_calls

Xref: https://github.com/nodejs/node/pull/49912

no code changes; patch just needed an update due to nearby upstream changes

* chore: update chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch

Xref: https://github.com/nodejs/node/pull/49986

minor manual changes needed to sync with upstream change

* update fix_expose_the_built-in_electron_module_via_the_esm_loader.patch

Xref: https://github.com/nodejs/node/pull/50096
Xref: https://github.com/nodejs/node/pull/50314
in lib/internal/modules/esm/load.js, update the code that checks for
`format === 'electron'`. I'd like 👀 on this

Xref: https://github.com/nodejs/node/pull/49657
add braces in lib/internal/modules/esm/translators.js to sync with upstream

* fix: lazyload fs in esm loaders to apply asar patches

* https://github.com/nodejs/node/pull/50127
* https://github.com/nodejs/node/pull/50096

* esm: jsdoc for modules code

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

* test: set test-cli-node-options as flaky

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

* deps: update c-ares to 1.20.1

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

* esm: bypass CommonJS loader under --default-type=module

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

* deps: update uvwasi to 0.0.19

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

* lib,test: do not hardcode Buffer.kMaxLength

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

* crypto: account for disabled SharedArrayBuffer

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

* test: fix edge snapshot stack traces

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

* src: generate snapshot with --predictable

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

* chore: fixup patch indices

* fs: throw errors from sync branches instead of separate implementations

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

* crypto: ensure valid point on elliptic curve in SubtleCrypto.importKey

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

* esm: detect ESM syntax in ambiguous JavaScrip

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

* fixup! test: fix edge snapshot stack traces

* esm: unflag extensionless ES module JavaScript and Wasm in module scope

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

* [tagged-ptr] Arrowify objects

4705331

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
electron-roller[bot] 2023-12-11 21:09:50 +01:00 committed by GitHub
parent 5094cb4115
commit 890a557eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 279 additions and 599 deletions

2
DEPS
View file

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

View file

@ -29,18 +29,13 @@ test_formally_mark_some_tests_as_flaky.patch
fix_adapt_debugger_tests_for_upstream_v8_changes.patch
chore_remove_--no-harmony-atomics_related_code.patch
fix_account_for_createexternalizablestring_v8_global.patch
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
ci_ensure_node_tests_set_electron_run_as_node.patch
fix_assert_module_in_the_renderer_process.patch
fix_add_trusted_space_and_trusted_lo_space_to_the_v8_heap.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
fix_avx_detection.patch
src_avoid_copying_string_in_fs_permission.patch
@ -48,3 +43,4 @@ 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
fix_-wshadow_error_in_uvwasi_c.patch

View file

@ -590,10 +590,10 @@ index 0000000000000000000000000000000000000000..9b97aabe865e4cf12f6c3ccda196b372
+}
diff --git a/deps/cares/BUILD.gn b/deps/cares/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5a30719e4
index 0000000000000000000000000000000000000000..fb1b3138cdb674205afa0ffe078270585843eca3
--- /dev/null
+++ b/deps/cares/BUILD.gn
@@ -0,0 +1,135 @@
@@ -0,0 +1,143 @@
+config("cares_config") {
+ include_dirs = [ "include", "src/lib" ]
+}
@ -618,8 +618,26 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares__addrinfo2hostent.c",
+ "src/lib/ares__addrinfo_localhost.c",
+ "src/lib/ares_android.c",
+ "src/lib/ares_cancel.c",
+ "src/lib/ares__buf.c",
+ "src/lib/ares__buf.h",
+ "src/lib/ares__close_sockets.c",
+ "src/lib/ares__htable.c",
+ "src/lib/ares__htable.h",
+ "src/lib/ares__htable_asvp.c",
+ "src/lib/ares__htable_asvp.h",
+ "src/lib/ares__htable_stvp.c",
+ "src/lib/ares__htable_stvp.h",
+ "src/lib/ares__llist.c",
+ "src/lib/ares__llist.h",
+ "src/lib/ares__get_hostent.c",
+ "src/lib/ares__parse_into_addrinfo.c",
+ "src/lib/ares__read_line.c",
+ "src/lib/ares__readaddrinfo.c",
+ "src/lib/ares__slist.c",
+ "src/lib/ares__slist.h",
+ "src/lib/ares__sortaddrinfo.c",
+ "src/lib/ares__timeval.c",
+ "src/lib/ares_cancel.c",
+ "src/lib/ares_create_query.c",
+ "src/lib/ares_data.c",
+ "src/lib/ares_data.h",
@ -630,25 +648,22 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares_free_hostent.c",
+ "src/lib/ares_free_string.c",
+ "src/lib/ares_freeaddrinfo.c",
+ "src/lib/ares_getenv.h",
+ "src/lib/ares_getaddrinfo.c",
+ "src/lib/ares_getenv.h",
+ "src/lib/ares_gethostbyaddr.c",
+ "src/lib/ares_gethostbyname.c",
+ "src/lib/ares__get_hostent.c",
+ "src/lib/ares_getnameinfo.c",
+ "src/lib/ares_getsock.c",
+ "src/lib/ares_inet_net_pton.h",
+ "src/lib/ares_init.c",
+ "src/lib/ares_ipv6.h",
+ "src/lib/ares_library_init.c",
+ "src/lib/ares_library_init.h",
+ "src/lib/ares_llist.c",
+ "src/lib/ares_llist.h",
+ "src/lib/ares_mkquery.c",
+ "src/lib/ares_nameser.h",
+ "src/lib/ares_nowarn.c",
+ "src/lib/ares_nowarn.h",
+ "src/lib/ares_options.c",
+ "src/lib/ares__parse_into_addrinfo.c",
+ "src/lib/ares_parse_aaaa_reply.c",
+ "src/lib/ares_parse_a_reply.c",
+ "src/lib/ares_parse_caa_reply.c",
@ -665,12 +680,9 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares_process.c",
+ "src/lib/ares_query.c",
+ "src/lib/ares_rand.c",
+ "src/lib/ares__read_line.c",
+ "src/lib/ares__readaddrinfo.c",
+ "src/lib/ares_search.c",
+ "src/lib/ares_send.c",
+ "src/lib/ares_setup.h",
+ "src/lib/ares__sortaddrinfo.c",
+ "src/lib/ares_strcasecmp.c",
+ "src/lib/ares_strcasecmp.h",
+ "src/lib/ares_strdup.c",
@ -678,15 +690,11 @@ index 0000000000000000000000000000000000000000..2a902c68ca445b8451e442c314c60ee5
+ "src/lib/ares_strerror.c",
+ "src/lib/ares_strsplit.c",
+ "src/lib/ares_timeout.c",
+ "src/lib/ares__timeval.c",
+ "src/lib/ares_version.c",
+ "src/lib/ares_writev.c",
+ "src/lib/ares_writev.h",
+ "src/lib/bitncmp.c",
+ "src/lib/bitncmp.h",
+ "src/lib/inet_net_pton.c",
+ "src/lib/inet_ntop.c",
+ "src/lib/ares_inet_net_pton.h",
+ "src/lib/setup_once.h",
+ "src/tools/ares_getopt.c",
+ "src/tools/ares_getopt.h",
@ -1131,10 +1139,10 @@ index 0000000000000000000000000000000000000000..7518168141db7958550c7f5dc1ed17cc
+}
diff --git a/deps/uvwasi/BUILD.gn b/deps/uvwasi/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df6369a765c07
index 0000000000000000000000000000000000000000..d9fcf8dc972b1caa2b7a130b1144c685316035cd
--- /dev/null
+++ b/deps/uvwasi/BUILD.gn
@@ -0,0 +1,38 @@
@@ -0,0 +1,39 @@
+config("uvwasi_config") {
+ include_dirs = [ "include" ]
+}
@ -1167,6 +1175,7 @@ index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df636
+ "src/fd_table.c",
+ "src/path_resolver.c",
+ "src/poll_oneoff.c",
+ "src/sync_helpers.c",
+ "src/uv_mapping.c",
+ "src/uvwasi.c",
+ "src/wasi_rights.c",
@ -1175,10 +1184,10 @@ index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df636
+}
diff --git a/filenames.json b/filenames.json
new file mode 100644
index 0000000000000000000000000000000000000000..aa118ab320d83745723a2275efc556555c1e7768
index 0000000000000000000000000000000000000000..cf88cae11d5fe0f4436688d41f4bf90892392d36
--- /dev/null
+++ b/filenames.json
@@ -0,0 +1,733 @@
@@ -0,0 +1,732 @@
+// This file is automatically generated by generate_gn_filenames_json.py
+// DO NOT EDIT
+{
@ -1191,7 +1200,6 @@ index 0000000000000000000000000000000000000000..aa118ab320d83745723a2275efc55655
+ "lib/internal/fs/recursive_watch.js",
+ "lib/internal/fs/rimraf.js",
+ "lib/internal/fs/streams.js",
+ "lib/internal/fs/sync.js",
+ "lib/internal/fs/sync_write_stream.js",
+ "lib/internal/fs/utils.js",
+ "lib/internal/fs/watchers.js",

View file

@ -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 a04a4a4e108862b64725345beaba73ad6f69eb51..f1c36cfd697485564f0fe7998eaf924aa30f140b 100644
index b7f9e44f827e58ac3b9376ec291f42cceb2b28bb..24cc9efe32c083d0cecd1ae94514b5a2d24ca2d6 100644
--- a/common.gypi
+++ b/common.gypi
@@ -79,6 +79,8 @@
@ -52,7 +52,7 @@ index 7b80ec63a082ce93ba81ca6dd41ec03041534ff7..926659883d3bd6d447c89a50d6770988
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 99d2e1384df4000d4e1f1ffeafa83d29a152054b..9ac0d5addcdd40d5c91d375b626099b95729548a 100644
index 868366f6d3e35d0fe543c89efd7d5e313a831a96..a512d2228e0afcfff765c3fe845e1f22073047d0 100644
--- a/src/node.h
+++ b/src/node.h
@@ -22,6 +22,12 @@

View file

@ -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 0b073571cd482d5124123c4490c564f839429b28..a04a4a4e108862b64725345beaba73ad6f69eb51 100644
index 225b3df380caca809926d6af9fc1001057237752..b7f9e44f827e58ac3b9376ec291f42cceb2b28bb 100644
--- a/common.gypi
+++ b/common.gypi
@@ -65,6 +65,7 @@

View file

@ -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 84fea979d482d3d5cacfad4b09237e6345675cad..678ed0a7b43c30c5dd6102d83f490e23c95090ce 100644
index ea3b411a78495d0414b1956503b86cbd5f0ed765..ad4946a6d121d38f413878a3dcc360012d568ef6 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -1215,6 +1215,13 @@ Module.prototype._compile = function(content, filename) {
@@ -1351,6 +1351,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,22 +26,24 @@ index 84fea979d482d3d5cacfad4b09237e6345675cad..678ed0a7b43c30c5dd6102d83f490e23
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 0dc769846b4e6fe84438cd6d8024c4a89eb90a9b..bff9bdc7ad58183e9eb04ee45b76592b4240952a 100644
index 66dfd7c1e521f38691e4656ac7ab0572a2fe75da..5db54daaa9e7066561d1621f2f0a01032ca7ff22 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -204,11 +204,13 @@ function patchProcessObject(expandArgv1) {
@@ -218,12 +218,14 @@ function patchProcessObject(expandArgv1) {
if (expandArgv1 && process.argv[1] &&
!StringPrototypeStartsWith(process.argv[1], '-')) {
// Expand process.argv[1] into a full path.
- const path = require('path');
- try {
- process.argv[1] = path.resolve(process.argv[1]);
- mainEntry = path.resolve(process.argv[1]);
- process.argv[1] = mainEntry;
- } catch {
- // Continue regardless of error.
+ if (!process.argv[1] || !process.argv[1].startsWith('electron/js2c')) {
+ const path = require('path');
+ try {
+ process.argv[1] = path.resolve(process.argv[1]);
+ mainEntry = path.resolve(process.argv[1]);
+ process.argv[1] = mainEntry;
+ } catch {
+ // Continue regardless of error.
+ }

View file

@ -11,10 +11,10 @@ its own blended handler between Node and Blink.
Not upstreamable.
diff --git a/lib/internal/modules/esm/utils.js b/lib/internal/modules/esm/utils.js
index 985784383024450833a8324d45a7af2fe214a09c..356c10aef57454be3b4607156606784f473042cf 100644
index 41077285452eac05766a22c2e1d252868e7e548b..2246e57efcf0b95903644d643ad5572717ecdaf4 100644
--- a/lib/internal/modules/esm/utils.js
+++ b/lib/internal/modules/esm/utils.js
@@ -16,7 +16,7 @@ const {
@@ -22,7 +22,7 @@ const {
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING,
ERR_INVALID_ARG_VALUE,
} = require('internal/errors').codes;
@ -23,9 +23,9 @@ index 985784383024450833a8324d45a7af2fe214a09c..356c10aef57454be3b4607156606784f
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;
@@ -190,12 +190,13 @@ let _isLoaderWorker = false;
* @param {boolean} [isLoaderWorker=false] - A boolean indicating whether the loader is a worker or not.
*/
function initializeESM(isLoaderWorker = false) {
+ const shouldSetOnIsolate = !getEmbedderOptions().shouldNotRegisterESMLoader;
_isLoaderWorker = isLoaderWorker;
@ -38,9 +38,9 @@ index 985784383024450833a8324d45a7af2fe214a09c..356c10aef57454be3b4607156606784f
+ setImportModuleDynamicallyCallback(importModuleDynamicallyCallback, shouldSetOnIsolate);
}
function isLoaderWorker() {
/**
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29a3ac678f 100644
index 52c30dcb47d1faba0c2267e4381a624e450baa02..ba4c1a0d5a987e4d410b49f5c47166943bd101a6 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -547,7 +547,7 @@ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback(
@ -52,7 +52,7 @@ index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29
Local<Context> context,
Local<v8::Data> host_defined_options,
Local<Value> resource_name,
@@ -610,12 +610,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
@@ -608,12 +608,13 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
Environment* env = Environment::GetCurrent(args);
HandleScope handle_scope(isolate);
@ -68,7 +68,7 @@ index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29
}
void ModuleWrap::HostInitializeImportMetaObjectCallback(
@@ -652,13 +653,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
@@ -650,13 +651,14 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback(
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
@ -87,7 +87,7 @@ index a1b0f812391486c5a429398326091a30bbe81692..a316d077f2d2ff38564959345cf8ef29
MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(
diff --git a/src/module_wrap.h b/src/module_wrap.h
index 6435bad40936fe235822c0597310b94ab98082f3..c51eb99ce3eb54bc30ae922e0357b637b09d53c6 100644
index 1fc801edced9c5e44613846b4dc555804c5bae97..23a0d7aee1dfa0ebe26e0507e31eacb0b4d137ed 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -30,7 +30,14 @@ enum HostDefinedOptions : int {

View file

@ -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 0bd0fc18534f8b3106b79a010dfc4ffe0ab17ec3..838ee86f74ea89e052676a5c25e23481369857fa 100644
index 88f40281e069b77ac071ac872c4491f749b64e21..0fa102da111fa370406ca74069316fa7a7a3a050 100644
--- a/test/common/assertSnapshot.js
+++ b/test/common/assertSnapshot.js
@@ -76,6 +76,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
@@ -80,6 +80,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,10 +47,31 @@ index 5a1b9feb6c8bedb50b89f5c4f3c5983455bb042d..efca7811dc0b6a590c5ee023c7180170
});
}
diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs
index 4c4fc08c0cf3828d11aefe9f12318001bf10c16d..b08bcd40cdf26093e158c0bb9ae566c76f2c731e 100644
index c0acee2bfc8c124e9d9b254041589a49c8301b8f..0e266899ffc0918b2f94e8f636043a6ec5f0870f 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -61,6 +61,7 @@ describe('errors output', { concurrency: true }, () => {
@@ -61,21 +61,22 @@ describe('errors output', { concurrency: true }, () => {
{ name: 'errors/events_unhandled_error_subclass.js', transform: errTransform },
{ name: 'errors/if-error-has-good-stack.js', transform: errTransform },
{ name: 'errors/throw_custom_error.js', transform: errTransform },
- { name: 'errors/throw_error_with_getter_throw.js', transform: errTransform },
+ // { name: 'errors/throw_error_with_getter_throw.js', transform: errTransform },
{ name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
{ name: 'errors/throw_non_error.js', transform: errTransform },
- { name: 'errors/throw_null.js', transform: errTransform },
- { name: 'errors/throw_undefined.js', transform: errTransform },
+ // { name: 'errors/throw_null.js', transform: errTransform },
+ // { name: 'errors/throw_undefined.js', transform: errTransform },
{ name: 'errors/timeout_throw.js', transform: errTransform },
{ name: 'errors/undefined_reference_in_new_context.js', transform: errTransform },
{ name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
- { name: 'errors/promise_unhandled_warn_with_error.js', transform: promiseTransform },
+ // { name: 'errors/promise_unhandled_warn_with_error.js', transform: promiseTransform },
{ name: 'errors/unhandled_promise_trace_warnings.js', transform: promiseTransform },
- { skip: skipForceColors, name: 'errors/force_colors.js',
- transform: forceColorsTransform, env: { FORCE_COLOR: 1 } },
+ // { skip: skipForceColors, name: 'errors/force_colors.js',
+ // transform: forceColorsTransform, env: { FORCE_COLOR: 1 } },
];
for (const { name, transform = defaultTransform, env, skip = false } of tests) {
it(name, { skip }, async () => {

View file

@ -34,7 +34,7 @@ index afe67d2237ae6933de44dd1141cf388e9a48cee3..87df6e1f32e584aa0c6ae21856299fff
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 f0b4cc43c864aee1fab8e073ea110ea108c653ab..6d12e27b955fb9fddab24d846e563c969bb48ae7 100644
index de372400fd9cedb0a724ce434c8944760dd2d078..58eb4befb94a68aa8f27c11665e9d7b32fe472be 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -707,8 +707,10 @@ bool Agent::Start(const std::string& path,
@ -51,10 +51,10 @@ index f0b4cc43c864aee1fab8e073ea110ea108c653ab..6d12e27b955fb9fddab24d846e563c96
parent_env_->AddCleanupHook([](void* data) {
Environment* env = static_cast<Environment*>(data);
diff --git a/src/node.h b/src/node.h
index dcce529664e1d126115545d6ba7f5b8492b0e921..99d2e1384df4000d4e1f1ffeafa83d29a152054b 100644
index 74a097279d3e5dc3ee6c5e609fd35cf44e5002f5..868366f6d3e35d0fe543c89efd7d5e313a831a96 100644
--- a/src/node.h
+++ b/src/node.h
@@ -654,7 +654,11 @@ enum Flags : uint64_t {
@@ -656,7 +656,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.

View file

@ -6,7 +6,7 @@ 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 1f4a08515b5ae9e15ee987d9287f71b0fed3cb30..0dc769846b4e6fe84438cd6d8024c4a89eb90a9b 100644
index 917ba90a1c8bbbff5d86e5f2079d1ce67237280e..66dfd7c1e521f38691e4656ac7ab0572a2fe75da 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -67,6 +67,8 @@ function prepareWorkerThreadExecution() {
@ -18,7 +18,7 @@ index 1f4a08515b5ae9e15ee987d9287f71b0fed3cb30..0dc769846b4e6fe84438cd6d8024c4a8
function prepareExecution(options) {
const { expandArgv1, initializeModules, isMainThread } = options;
@@ -170,12 +172,17 @@ function setupUserModules(isLoaderWorker = false) {
@@ -172,12 +174,17 @@ function setupUserModules(isLoaderWorker = false) {
loadPreloadModules();
// Need to be done after --require setup.
initializeFrozenIntrinsics();
@ -33,6 +33,6 @@ index 1f4a08515b5ae9e15ee987d9287f71b0fed3cb30..0dc769846b4e6fe84438cd6d8024c4a8
+ processLinkedBinding('electron_common_asar').initAsarSupport(require);
+}
+
function patchProcessObject(expandArgv1) {
const binding = internalBinding('process_methods');
binding.patchProcessObject(process);
/**
* Patch the process object with legacy properties and normalizations.
* Replace `process.argv[0]` with `process.execPath`, preserving the original `argv[0]` value as `process.argv0`.

View file

@ -10,7 +10,7 @@ already been called.
This should be upstreamed.
diff --git a/src/node.cc b/src/node.cc
index 89e0e5524c2102b86bc5506fe49aa0c6fa0f30c1..e58f28e0f0ff8d61f35ec3c5a69aa37c66c25d78 100644
index a9336a14304fc673c02ae5b7e5ca82aec9fa6697..7a6a9cdddf00c91612c2bcabf40a5c4af16424df 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -605,6 +605,7 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
@ -22,17 +22,17 @@ index 89e0e5524c2102b86bc5506fe49aa0c6fa0f30c1..e58f28e0f0ff8d61f35ec3c5a69aa37c
#endif // NODE_USE_V8_WASM_TRAP_HANDLER
}
diff --git a/src/node.h b/src/node.h
index 9ac0d5addcdd40d5c91d375b626099b95729548a..3ffc51783b0b6dee1c0f0a37d2f52cb1aec2fa3f 100644
index a512d2228e0afcfff765c3fe845e1f22073047d0..36da93a7b41ea450a5f288ec17b61adae46ae178 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.
@@ -274,6 +274,10 @@ enum Flags : uint32_t {
kNoInitializeCppgc = 1 << 13,
// Initialize the process for predictable snapshot generation.
kGeneratePredictableSnapshot = 1 << 14,
+ // 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,
+ kNoEnableWasmTrapHandler = 1 << 15,
// Emulate the behavior of InitializeNodeWithArgs() when passing
// a flags argument to the InitializeOncePerProcess() replacement

View file

@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Fri, 8 Dec 2023 18:05:28 +0100
Subject: fix: -Wshadow error in uvwasi.c
Refs https://github.com/nodejs/node/pull/49908
Fixes a -Wshadow error in uvwasi.c. This should be upstreamed.
diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c
index e904b9f9293864db02f660dc3c9737f0e3684355..3e9cce85cae109ffc09f6b86ab5e896620b862d8 100644
--- a/deps/uvwasi/src/uvwasi.c
+++ b/deps/uvwasi/src/uvwasi.c
@@ -2794,13 +2794,13 @@ uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
goto close_sock_and_error_exit;
}
- int r = uv_accept((uv_stream_t*) wrap->sock, (uv_stream_t*) uv_connect_sock);
- if (r == UV_EAGAIN) {
+ int rr = uv_accept((uv_stream_t*) wrap->sock, (uv_stream_t*) uv_connect_sock);
+ if (rr == UV_EAGAIN) {
// still no connection or error so run the loop again
continue;
}
- if (r != 0) {
+ if (rr != 0) {
// An error occurred accepting the connection. Break out of the loop and
// report an error.
err = uvwasi__translate_uv_error(r);

View file

@ -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 d783c7f970237a648f585b9a9e5725494b5d9e2f..0b073571cd482d5124123c4490c564f839429b28 100644
index 4589f515178093402b4abc265af041037ee22f3b..225b3df380caca809926d6af9fc1001057237752 100644
--- a/common.gypi
+++ b/common.gypi
@@ -80,6 +80,23 @@

View file

@ -58,10 +58,10 @@ index c02906eacd90ac27d618e7578d1f928f16a858f7..74b4e15b8230c6380d41e84aa504824b
}
diff --git a/src/node_options.cc b/src/node_options.cc
index f711ac936e76f9c16d15d7db759d0081a9eb018d..6eb2c137e1dd05b05e781820905cf6778107275d 100644
index faca807e31daaadb0103556001a16629a3822c1f..9011eda7ce2435c2f859cacbac55cdc6182ebccc 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -1239,6 +1239,11 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
@@ -1262,6 +1262,11 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
Local<Context> context = env->context();
Local<Object> ret = Object::New(isolate);

View file

@ -381,7 +381,7 @@ index fcf1922bcdba733af6c22f142db4f7b099947757..9f72ae4e41a113e752f40795103c2af5
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
index 3b738b7f47ec59ba718a92e3a0024fed45a9c87c..fabf5775a263804f5974b10cf73c6886d59bf1fa 100644
--- a/test/parallel/test-crypto-dh.js
+++ b/test/parallel/test-crypto-dh.js
@@ -55,18 +55,17 @@ const crypto = require('crypto');
@ -411,7 +411,7 @@ index abbe1abe7e53d7bd113afb68b0e9af1e814c70bd..086a8e38021ed1a87be22246cdb4f5ce
};
}
@@ -95,10 +94,16 @@ const crypto = require('crypto');
@@ -99,10 +98,16 @@ const crypto = require('crypto');
// Through a fluke of history, g=0 defaults to DH_GENERATOR (2).
{
const g = 0;

View file

@ -5,33 +5,57 @@ Subject: fix: do not resolve electron entrypoints
This wastes fs cycles and can result in strange behavior if this path actually exists on disk
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index 8406e8ca319533d6186c5d457e951b7a845b6b72..caa34187e17d9a0addcc8c94e46823ea4e05c590 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -131,7 +131,7 @@ async function defaultLoad(url, context = kEmptyObject) {
format ??= 'builtin';
} else {
let contextToPass = context;
- if (source == null) {
+ if (format !== 'electron' && source == null) {
({ responseURL, source } = await getSource(urlInstance, context));
contextToPass = { __proto__: context, source };
}
@@ -139,7 +139,7 @@ async function defaultLoad(url, context = kEmptyObject) {
// Now that we have the source for the module, run `defaultGetFormat` again in case we detect ESM syntax.
format ??= await defaultGetFormat(urlInstance, contextToPass);
- if ((format === 'commonjs' || format === 'electron') && contextToPass !== context) {
+ if (format === 'electron' || format === 'commonjs' && contextToPass !== context) {
// For backward compatibility reasons, we need to discard the source in
// order for the CJS loader to re-fetch it.
source = null;
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 4c3a0d8c484a402fe419a0bd45c7e2b1d717cb4a..b8be4cde3bbe4b14e607a2bef0a2405df3cae533 100644
index dbbe37474c70addfbf8cf805c29732dcd38c74f6..96ffb2b0b051163d8a777ed3d1b5bc2c83fc37c5 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)
@@ -376,6 +376,9 @@ function cjsPreparseModuleExports(filename, source) {
if (cached) {
return { module, exportNames: cached.exportNames };
+ if (filename === 'electron')
+ return { module };
}
+ if (filename === 'electron') {
+ return { module, exportNames: new SafeSet(['default', ...Object.keys(module.exports)]) };
+ }
}
const loaded = Boolean(module);
if (!loaded) {
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
index 0bfe7b11241416bfca0d470047b14777ad99307f..c86add4395ed59cee0d880961e7572b0cc3d6698 100644
index 1f03c313121db054ff824d07e57c57c749005497..2c8aa6461497f39062ec350ef8a063b9b0ac1edf 100644
--- a/lib/internal/modules/run_main.js
+++ b/lib/internal/modules/run_main.js
@@ -2,12 +2,19 @@
@@ -2,6 +2,7 @@
const {
StringPrototypeEndsWith,
+ StringPrototypeStartsWith,
} = primordials;
const { getOptionValue } = require('internal/options');
const path = require('path');
const { containsModuleSyntax } = internalBinding('contextify');
@@ -13,6 +14,13 @@ const path = require('path');
* @param {string} main - Entry point path
*/
function resolveMainPath(main) {
+ // For built-in modules used as the main entry point we _never_
+ // want to waste cycles resolving them to file paths on disk
@ -39,12 +63,13 @@ index 0bfe7b11241416bfca0d470047b14777ad99307f..c86add4395ed59cee0d880961e7572b0
+ 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.
@@ -24,6 +31,12 @@ function resolveMainPath(main) {
}
+
const defaultType = getOptionValue('--experimental-default-type');
/** @type {string} */
let mainPath;
@@ -50,6 +58,13 @@ function resolveMainPath(main) {
* @param {string} mainPath - Absolute path to the main entry point
*/
function shouldUseESMLoader(mainPath) {
+ // For built-in modules used as the main entry point we _never_
+ // want to waste cycles resolving them to file paths on disk
@ -52,6 +77,7 @@ index 0bfe7b11241416bfca0d470047b14777ad99307f..c86add4395ed59cee0d880961e7572b0
+ if (typeof mainPath === 'string' && StringPrototypeStartsWith(mainPath, 'electron/js2c')) {
+ return false;
+ }
+
if (getOptionValue('--experimental-default-type') === 'module') { return true; }
/**
* @type {string[]} userLoaders A list of custom loaders registered by the user
* (or an empty list when none have been registered).

View file

@ -6,10 +6,10 @@ 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 4ac9c011d153f4cb39cb7d4f46de0f8e65f70a56..f8462b69368aa7987e1e8ac8cd73e4ff2d921c51 100644
index 1931688e85d05ee2da4f88efb05d635cb43be233..afccc24392abff9eef2b9953fcffeb79ee71ad15 100644
--- a/lib/internal/modules/esm/get_format.js
+++ b/lib/internal/modules/esm/get_format.js
@@ -27,6 +27,7 @@ const protocolHandlers = {
@@ -30,6 +30,7 @@ const protocolHandlers = {
'http:': getHttpProtocolModuleFormat,
'https:': getHttpProtocolModuleFormat,
'node:'() { return 'builtin'; },
@ -18,20 +18,19 @@ index 4ac9c011d153f4cb39cb7d4f46de0f8e65f70a56..f8462b69368aa7987e1e8ac8cd73e4ff
/**
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index d064296d11c463616111d28a32b7ad3f6a72bebd..14d5236d0ead946acf9a2f63bf979e7193bfbf56 100644
index 6f9b73abd8a76191714f12d68c01a881653d8d4a..f108b567a910805ff86f0baf75fa1a6102ad28d6 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -123,7 +123,8 @@ async function defaultLoad(url, context = kEmptyObject) {
@@ -140,7 +140,7 @@ async function defaultLoad(url, context = kEmptyObject) {
// Now that we have the source for the module, run `defaultGetFormat` again in case we detect ESM syntax.
format ??= await defaultGetFormat(urlInstance, contextToPass);
if (
format === 'builtin' ||
- format === 'commonjs'
+ format === 'commonjs' ||
+ format === 'electron'
) {
source = null;
} else if (source == null) {
@@ -201,6 +202,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
- if (format === 'commonjs' && contextToPass !== context) {
+ if ((format === 'commonjs' || format === 'electron') && contextToPass !== context) {
// For backward compatibility reasons, we need to discard the source in
// order for the CJS loader to re-fetch it.
source = null;
@@ -221,6 +221,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
protocol !== 'file:' &&
protocol !== 'data:' &&
protocol !== 'node:' &&
@ -39,7 +38,7 @@ index d064296d11c463616111d28a32b7ad3f6a72bebd..14d5236d0ead946acf9a2f63bf979e71
(
!experimentalNetworkImports ||
(
@@ -209,7 +211,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
@@ -229,7 +230,7 @@ function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
)
)
) {
@ -49,19 +48,19 @@ index d064296d11c463616111d28a32b7ad3f6a72bebd..14d5236d0ead946acf9a2f63bf979e71
ArrayPrototypePush(schemes, 'https', 'http');
}
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
index acb5ddca8af3d2495ce27d6426b28e6ff73a8f33..acfcc1f1f92548117ded857fa8d4dd140e07ab2b 100644
index 58e7df07ca5275e3a684f30c3d0a3f901d000fb8..2d077cc182b40e0bdce2d71d0471e96e6d30222a 100644
--- a/lib/internal/modules/esm/resolve.js
+++ b/lib/internal/modules/esm/resolve.js
@@ -725,6 +725,8 @@ function parsePackageName(specifier, base) {
return { packageName, packageSubpath, isScoped };
@@ -731,6 +731,8 @@ function packageImportsResolve(name, base, conditions) {
throw importNotDefined(name, packageJSONUrl, base);
}
+const electronTypes = ['electron', 'electron/main', 'electron/common', 'electron/renderer'];
+
/**
* @param {string} specifier
* @param {string | URL | undefined} base
@@ -736,6 +738,11 @@ function packageResolve(specifier, base, conditions) {
* Returns the package type for a given URL.
* @param {URL} url - The URL to get the package type for.
@@ -791,6 +793,11 @@ function packageResolve(specifier, base, conditions) {
return new URL('node:' + specifier);
}
@ -74,10 +73,10 @@ index acb5ddca8af3d2495ce27d6426b28e6ff73a8f33..acfcc1f1f92548117ded857fa8d4dd14
parsePackageName(specifier, base);
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index b143cd0ad34d0e039db3e7493be00d923cc68b2d..178f362b2869173d51b2e97a8d35a16ab4ed4962 100644
index 7a62615cfe4210c9fd83c6bfa3b5da19eec5fff2..bda102b266b17936efc453d039213517c4ef921c 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -220,7 +220,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
@@ -280,7 +280,7 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
const { exportNames, module } = cjsPreparseModuleExports(filename, source);
cjsCache.set(url, module);
@ -86,20 +85,18 @@ index b143cd0ad34d0e039db3e7493be00d923cc68b2d..178f362b2869173d51b2e97a8d35a16a
[...exportNames] : ['default', ...exportNames];
if (isMain) {
@@ -241,9 +241,9 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
} else {
@@ -302,8 +302,8 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
({ exports } = module);
}
- for (const exportName of exportNames) {
for (const exportName of exportNames) {
- if (!ObjectPrototypeHasOwnProperty(exports, exportName) ||
- exportName === 'default')
+ for (const exportName of namesWithDefault) {
- exportName === 'default') {
+ if (exportName === 'default' ||
+ !ObjectPrototypeHasOwnProperty(exports, exportName))
+ !ObjectPrototypeHasOwnProperty(exports, exportName)) {
continue;
}
// We might trigger a getter -> dont fail.
let value;
@@ -267,6 +267,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
@@ -328,6 +328,10 @@ translators.set('require-commonjs', (url, source, isMain) => {
return createCJSModuleWrap(url, source);
});
@ -111,7 +108,7 @@ index b143cd0ad34d0e039db3e7493be00d923cc68b2d..178f362b2869173d51b2e97a8d35a16a
// 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 8d5926e8fcb9df031e37698588075a34a80aea6c..6df0b68c8d35445d5f02475678484a6d5157762e 100644
index a58f96aee7cc424ce18fe647afff8724f8a179a0..ae618cdeac1dfa1fd0ddcceb9edc83e06c59fc4b 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -1389,6 +1389,8 @@ function fileURLToPath(path) {

View file

@ -22,7 +22,7 @@ index 6a6164b6d294430b6f2fe826cdcef5a9cc3f9660..035f495687856b0cfbcc4e87ba6e90d5
int thread_pool_size,
node::tracing::TracingController* tracing_controller) {
diff --git a/src/node.h b/src/node.h
index ca01c42e8af484def476ba27cb270a0cc90226c9..dcce529664e1d126115545d6ba7f5b8492b0e921 100644
index f2740116a4710be31d8c8d3a03f9ea3925301b31..74a097279d3e5dc3ee6c5e609fd35cf44e5002f5 100644
--- a/src/node.h
+++ b/src/node.h
@@ -132,6 +132,7 @@ struct SnapshotData;
@ -33,7 +33,7 @@ index ca01c42e8af484def476ba27cb270a0cc90226c9..dcce529664e1d126115545d6ba7f5b84
class TracingController;
}
@@ -772,6 +773,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
@@ -774,6 +775,8 @@ NODE_EXTERN void GetNodeReport(Environment* env,
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);

View file

@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Wed, 19 Jul 2023 16:00:08 -0500
Subject: fix ftbfs Werror Wextra-semi
Fix a deps warning that causes FTBFS when building with -Werror.
This patch can be removed if fixed upstream.
Upstream PR: https://github.com/nodejs/uvwasi/pull/217
diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c
index 9e7fc7681664b8430bbd2d2324352be8c6735106..708a52b0621666133b5215790cb9d5fd6a71d4fa 100644
--- a/deps/uvwasi/src/uvwasi.c
+++ b/deps/uvwasi/src/uvwasi.c
@@ -2564,7 +2564,7 @@ uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
/* TODO(mhdawson): Needs implementation */
UVWASI_DEBUG("uvwasi_sock_accept(uvwasi=%p, unimplemented)\n", uvwasi);
return UVWASI_ENOTSUP;
-};
+}
const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code) {
@@ -2651,4 +2651,4 @@ const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code) {
default:
return "UVWASI_UNKNOWN_ERROR";
}
-}
+}
\ No newline at end of file

View file

@ -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 3876adf7d72211d8d8c5a94564168094ecfc660b..ccd166d9439a821328d2ad35352488960206f65e 100644
index 6e5bbe07d0c337b36f3157c2e6404fdc91849fd1..7ec682833213de9054a8c30751436d12baaea235 100644
--- a/src/crypto/crypto_context.cc
+++ b/src/crypto/crypto_context.cc
@@ -63,7 +63,7 @@ inline X509_STORE* GetOrCreateRootCertStore() {
@ -240,6 +240,28 @@ index 3fa4a415dc911a13afd90dfb31c1ed4ad0fd268f..fa48dffc31342c44a1c1207b9d4c3dc7
if (EVP_PKEY_paramgen(param_ctx.get(), &raw_params) <= 0)
return EVPKeyCtxPointer();
diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc
index c5dd2fb8fce40f2bf6f9a8543047ffb50cc08084..d850af9257cc194ee385130ce3cd2c0101b2455f 100644
--- a/src/crypto/crypto_keys.cc
+++ b/src/crypto/crypto_keys.cc
@@ -1241,6 +1241,7 @@ void KeyObjectHandle::GetAsymmetricKeyType(
}
bool KeyObjectHandle::CheckEcKeyData() const {
+#ifndef OPENSSL_IS_BORINGSSL
MarkPopErrorOnReturn mark_pop_error_on_return;
const ManagedEVPPKey& key = data_->GetAsymmetricKey();
@@ -1259,6 +1260,9 @@ bool KeyObjectHandle::CheckEcKeyData() const {
#else
return EVP_PKEY_public_check(ctx.get()) == 1;
#endif
+#else
+ return true;
+#endif
}
void KeyObjectHandle::CheckEcKeyData(const FunctionCallbackInfo<Value>& args) {
diff --git a/src/crypto/crypto_random.cc b/src/crypto/crypto_random.cc
index 245f352918696413f8f0f7cec94dbcec687685af..35c1c1ce9f0e3d59b75e3966d485bf70b846de5b 100644
--- a/src/crypto/crypto_random.cc
@ -254,10 +276,10 @@ index 245f352918696413f8f0f7cec94dbcec687685af..35c1c1ce9f0e3d59b75e3966d485bf70
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 3f8499457cf10765fa55e5018a26580f2c5ef15d..31647423be528949db744cbea43586ece5243bac 100644
index f222ab9cf5ccbc5dd3399b18d7688efda6672c93..349abd4d06e7f624a071b994271dedc31dc9229a 100644
--- a/src/crypto/crypto_rsa.cc
+++ b/src/crypto/crypto_rsa.cc
@@ -610,10 +610,11 @@ Maybe<bool> GetRsaKeyDetail(
@@ -616,10 +616,11 @@ Maybe<bool> GetRsaKeyDetail(
}
if (params->saltLength != nullptr) {
@ -361,7 +383,7 @@ index cf051585e779e2b03bd7b95fe5008b89cc7f8162..9de49c6828468fdf846dcd4ad445390f
#if NODE_OPENSSL_HAS_QUIC
#include <openssl/quic.h>
diff --git a/src/node_options.cc b/src/node_options.cc
index b544f1209143c0d4a01b1df3257e5b2ba1d5bfee..f711ac936e76f9c16d15d7db759d0081a9eb018d 100644
index 29cb7fc6b29b89946856990032645ad4edb8529c..faca807e31daaadb0103556001a16629a3822c1f 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -6,7 +6,7 @@
@ -374,7 +396,7 @@ index b544f1209143c0d4a01b1df3257e5b2ba1d5bfee..f711ac936e76f9c16d15d7db759d0081
#endif
diff --git a/src/node_options.h b/src/node_options.h
index bc18a45e681a3cd8d26ea94862d7a6eb3a6631fc..08141c540c0c3fe4f2a4fe66bf75557a71a1d8e6 100644
index 30955c779714ce5ad9b79f11e4cfefbcada7fa05..f02c07cd418fa2e3c64221bd37acd380a130f608 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -11,7 +11,7 @@

View file

@ -1,37 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 2 Oct 2023 16:03:43 +0200
Subject: fix: handle possible disabled SharedArrayBuffer
It's possible for SharedArrayBuffer to be disabled with the -no-harmony-sharedarraybuffer
flag, and so we should guard uses with a check for potential undefined-ness.
This should be upstreamed to Node.js.
diff --git a/lib/internal/crypto/webidl.js b/lib/internal/crypto/webidl.js
index 9f5340c223902c5ff61def05e8a4f470b4f328e8..d6dbfa482f9ebff3f99fb810e072cf9a03d1cd4d 100644
--- a/lib/internal/crypto/webidl.js
+++ b/lib/internal/crypto/webidl.js
@@ -183,7 +183,10 @@ function isNonSharedArrayBuffer(V) {
return ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V);
}
+// SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
function isSharedArrayBuffer(V) {
+ if (SharedArrayBuffer === undefined)
+ return false;
return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V);
}
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
index 4460042d7bfbb8286a9b2abcbfb9e44f21b5d944..027a2de1878d5f09dc5d44b1b21af7163ea1b999 100644
--- a/lib/internal/main/worker_thread.js
+++ b/lib/internal/main/worker_thread.js
@@ -112,6 +112,7 @@ port.on('message', (message) => {
require('internal/worker').assignEnvironmentData(environmentData);
+ // SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
if (SharedArrayBuffer !== undefined) {
// The counter is only passed to the workers created by the main thread,
// not to workers created by other workers.

View file

@ -6,12 +6,12 @@ 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 14d5236d0ead946acf9a2f63bf979e7193bfbf56..74136abfb9aae1fc8ab746908be752056b6d7c5a 100644
index f108b567a910805ff86f0baf75fa1a6102ad28d6..8406e8ca319533d6186c5d457e951b7a845b6b72 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -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 { validateAttributes, emitImportAssertionWarning } = require('internal/modules/esm/assert');
const { getOptionValue } = require('internal/options');
-const { readFileSync } = require('fs');
+const fs = require('fs');
@ -38,7 +38,7 @@ index 14d5236d0ead946acf9a2f63bf979e7193bfbf56..74136abfb9aae1fc8ab746908be75205
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 acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62dcd760cce 100644
index 2d077cc182b40e0bdce2d71d0471e96e6d30222a..34fd6613fa24d628fc026ac11e5be7217a20fff4 100644
--- a/lib/internal/modules/esm/resolve.js
+++ b/lib/internal/modules/esm/resolve.js
@@ -24,7 +24,7 @@ const {
@ -50,7 +50,7 @@ index acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62d
const { getOptionValue } = require('internal/options');
// Do not eagerly grab .manifest, it may be in TDZ
const policy = getOptionValue('--experimental-policy') ?
@@ -235,7 +235,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
@@ -257,7 +257,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
}
if (!preserveSymlinks) {
@ -60,28 +60,19 @@ index acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62d
});
const { search, hash } = resolved;
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 178f362b2869173d51b2e97a8d35a16ab4ed4962..4c3a0d8c484a402fe419a0bd45c7e2b1d717cb4a 100644
index bda102b266b17936efc453d039213517c4ef921c..dbbe37474c70addfbf8cf805c29732dcd38c74f6 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -25,7 +25,7 @@ function lazyTypes() {
}
@@ -32,7 +32,7 @@ function lazyTypes() {
const { containsModuleSyntax } = internalBinding('contextify');
const assert = require('internal/assert');
-const { readFileSync } = require('fs');
+const fs = require('fs');
const { dirname, extname, isAbsolute } = require('path');
const {
hasEsmSyntax,
@@ -132,7 +132,7 @@ translators.set('module', async function moduleStrategy(url, source, isMain) {
*/
function enrichCJSError(err, content, filename) {
if (err != null && ObjectGetPrototypeOf(err) === SyntaxErrorPrototype &&
- hasEsmSyntax(content || readFileSync(filename, 'utf-8'))) {
+ hasEsmSyntax(content || fs.readFileSync(filename, 'utf-8'))) {
// 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.
@@ -294,7 +294,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
loadBuiltinModule,
@@ -355,7 +355,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
try {
// We still need to read the FS to detect the exports.
@ -90,12 +81,12 @@ index 178f362b2869173d51b2e97a8d35a16ab4ed4962..4c3a0d8c484a402fe419a0bd45c7e2b1
} catch {
// Continue regardless of error.
}
@@ -357,7 +357,7 @@ function cjsPreparseModuleExports(filename, source) {
@@ -424,7 +424,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)
for (const name of reexportNames) {
exportNames.add(name);

View file

@ -13,7 +13,7 @@ causing the following error:
This should be upstreamed.
diff --git a/src/module_wrap.h b/src/module_wrap.h
index c51eb99ce3eb54bc30ae922e0357b637b09d53c6..55317ced78ee9ceaa13f7e00477c59370eb335fa 100644
index 23a0d7aee1dfa0ebe26e0507e31eacb0b4d137ed..0733017d8e1ac6e60589082b402bd44a98ddc312 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -7,6 +7,7 @@

View file

@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Thu, 22 Jun 2023 11:59:47 -0500
Subject: fix: Wunreachable-code warning in ares__init_rand_engine()
Fix upstream Win32 FTBFS when building with -Werror,-Wunreachable-code.
This patch can be removed after the fix is picked up in Node.js.
Upstream PR @ https://github.com/c-ares/c-ares/pull/531
diff --git a/deps/cares/src/lib/ares_rand.c b/deps/cares/src/lib/ares_rand.c
index 766c1e6ea9bda1784cfb611dbac66424806cd23a..12d943921e3ba61cbf7a2ed3194fcd5a6c61da8a 100644
--- a/deps/cares/src/lib/ares_rand.c
+++ b/deps/cares/src/lib/ares_rand.c
@@ -55,6 +55,7 @@ BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG RandomBufferLength);
# endif
#endif
+#if !defined(HAVE_ARC4RANDOM_BUF) && !defined(_WIN32)
#define ARES_RC4_KEY_LEN 32 /* 256 bits */
@@ -129,6 +130,7 @@ static void ares_rc4_init(ares_rand_rc4 *rc4_state)
rc4_state->i = 0;
rc4_state->j = 0;
}
+#endif
/* Just outputs the key schedule, no need to XOR with any data since we have none */
static void ares_rc4_prng(ares_rand_rc4 *rc4_state, unsigned char *buf, size_t len)
@@ -166,13 +168,13 @@ static int ares__init_rand_engine(ares_rand_state *state)
return 1;
}
/* Fall-Thru on failure to RC4 */
-#endif
state->type = ARES_RAND_RC4;
ares_rc4_init(&state->state.rc4);
/* Currently cannot fail */
return 1;
+#endif
}
@@ -276,4 +278,3 @@ unsigned short ares__generate_new_id(ares_rand_state *state)
ares__rand_bytes(state, (unsigned char *)&r, sizeof(r));
return r;
}
-

View file

@ -1,155 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= <targos@protonmail.com>
Date: Thu, 28 Sep 2023 14:50:20 +0200
Subject: lib,test: do not hardcode Buffer.kMaxLength
V8 will soon support typed arrays as large as the maximum array buffer
length. This patch replaces hardcoded values related to
Buffer.kMaxLength with the actual constant.
It also fixes a test that was passing by accident.
Refs: https://github.com/v8/v8/commit/44b299590083b888637c79fb5632806e607ab861
PR-URL: https://github.com/nodejs/node/pull/49876
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
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 d0e47c1a4397a875c937d43c3b72dbd1e1de35a7..400d2c5fd21bc962a8befc4d80527216baddd6d5 100644
--- a/lib/internal/blob.js
+++ b/lib/internal/blob.js
@@ -24,6 +24,9 @@ const {
concat,
getDataObject,
} = internalBinding('blob');
+const {
+ kMaxLength,
+} = internalBinding('buffer');
const {
TextDecoder,
@@ -62,7 +65,6 @@ const {
} = require('internal/errors');
const {
- isUint32,
validateDictionary,
} = require('internal/validators');
@@ -158,8 +160,8 @@ class Blob {
return src;
});
- if (!isUint32(length))
- throw new ERR_BUFFER_TOO_LARGE(0xFFFFFFFF);
+ if (length > kMaxLength)
+ throw new ERR_BUFFER_TOO_LARGE(kMaxLength);
this[kHandle] = _createBlob(sources_, length);
this[kLength] = length;
diff --git a/test/parallel/test-blob-buffer-too-large.js b/test/parallel/test-blob-buffer-too-large.js
index 2fd8b8754bd593a0da069044d33fcd6bba82f9c9..a9cf53b025bbff58a8d5783e4f807d79f5d68e2b 100644
--- a/test/parallel/test-blob-buffer-too-large.js
+++ b/test/parallel/test-blob-buffer-too-large.js
@@ -3,17 +3,17 @@
const common = require('../common');
const assert = require('assert');
-const { Blob } = require('buffer');
+const { Blob, kMaxLength } = require('buffer');
if (common.isFreeBSD)
common.skip('Oversized buffer make the FreeBSD CI runner crash');
try {
- new Blob([new Uint8Array(0xffffffff), [1]]);
+ new Blob([new Uint8Array(kMaxLength), [1]]);
} catch (e) {
if (
e.message === 'Array buffer allocation failed' ||
- e.message === 'Invalid typed array length: 4294967295'
+ e.message === `Invalid typed array length: ${kMaxLength}`
) {
common.skip(
'Insufficient memory on this platform for oversized buffer test.'
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
index c6b728027057ece38c2b7fcc6bf7b18b959125d2..aad9c6bcab69e971c02281928885d94aa21c8199 100644
--- a/test/parallel/test-buffer-alloc.js
+++ b/test/parallel/test-buffer-alloc.js
@@ -4,13 +4,16 @@ const common = require('../common');
const assert = require('assert');
const vm = require('vm');
-const SlowBuffer = require('buffer').SlowBuffer;
+const {
+ SlowBuffer,
+ kMaxLength,
+} = require('buffer');
// Verify the maximum Uint8Array size. There is no concrete limit by spec. The
// internal limits should be updated if this fails.
assert.throws(
- () => new Uint8Array(2 ** 32 + 1),
- { message: 'Invalid typed array length: 4294967297' }
+ () => new Uint8Array(kMaxLength + 1),
+ { message: `Invalid typed array length: ${kMaxLength + 1}` },
);
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 d2df358cc00ca4b238252d6d11bdad3b77fad114..f29d6b62d4aa408fb3a67ffe71b14436fbbff907 100644
--- a/test/parallel/test-buffer-over-max-length.js
+++ b/test/parallel/test-buffer-over-max-length.js
@@ -12,18 +12,8 @@ const bufferMaxSizeMsg = {
name: 'RangeError',
};
-assert.throws(() => Buffer((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => SlowBuffer((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => Buffer.alloc((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => Buffer.allocUnsafe((-1 >>> 0) + 2), bufferMaxSizeMsg);
-assert.throws(() => Buffer.allocUnsafeSlow((-1 >>> 0) + 2), bufferMaxSizeMsg);
-
assert.throws(() => Buffer(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => SlowBuffer(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => Buffer.alloc(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg);
assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg);
-
-// issue GH-4331
-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 d2e1e0d6e46438f20d6b8f1196ebd936d4fa3436..0ebea759b5c42be0c294093256ea3cad7034a98b 100644
--- a/test/parallel/test-buffer-tostring-rangeerror.js
+++ b/test/parallel/test-buffer-tostring-rangeerror.js
@@ -1,17 +1,22 @@
'use strict';
require('../common');
-// This test ensures that Node.js throws a RangeError when trying to convert a
-// gigantic buffer into a string.
+// This test ensures that Node.js throws an Error when trying to convert a
+// large buffer into a string.
// Regression test for https://github.com/nodejs/node/issues/649.
const assert = require('assert');
-const SlowBuffer = require('buffer').SlowBuffer;
+const {
+ SlowBuffer,
+ constants: {
+ MAX_STRING_LENGTH,
+ },
+} = require('buffer');
-const len = 1422561062959;
+const len = MAX_STRING_LENGTH + 1;
const message = {
- code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError',
+ code: 'ERR_STRING_TOO_LONG',
+ name: 'Error',
};
assert.throws(() => Buffer(len).toString('utf8'), message);
assert.throws(() => SlowBuffer(len).toString('utf8'), message);

View file

@ -6,10 +6,10 @@ 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 19a7d7e671f5abfa55b62290dcf3796a2c4e9013..3161afa33889f1682a1689e76fbcadc397f4b01c 100644
index b077ee386bb40ea32208fc6655de88a3449b7eb2..f408d6c152d6acabea5ff3e262fe344909046595 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -142,6 +142,13 @@ const {
@@ -146,6 +146,13 @@ const {
CHAR_FORWARD_SLASH,
} = require('internal/constants');
@ -23,8 +23,8 @@ index 19a7d7e671f5abfa55b62290dcf3796a2c4e9013..3161afa33889f1682a1689e76fbcadc3
const {
isProxy,
} = require('internal/util/types');
@@ -1236,10 +1243,12 @@ Module.prototype._compile = function(content, filename) {
if (requireDepth === 0) statCache = new SafeMap();
@@ -1371,10 +1378,12 @@ Module.prototype._compile = function(content, filename) {
if (requireDepth === 0) { statCache = new SafeMap(); }
if (inspectorWrapper) {
result = inspectorWrapper(compiledWrapper, thisValue, exports,
- require, module, filename, dirname);
@ -37,4 +37,4 @@ index 19a7d7e671f5abfa55b62290dcf3796a2c4e9013..3161afa33889f1682a1689e76fbcadc3
+ dirname, process, localGlobal, localBuffer]);
}
hasLoadedAnyUserCJSModule = true;
if (requireDepth === 0) statCache = null;
if (requireDepth === 0) { statCache = null; }

View file

@ -22,21 +22,20 @@ index 7a773d5208e250abd8b0efb6dde66c45060bbee4..45e38ca0a122e3b1c5d8d59865f9610c
const binding = internalBinding('builtins');
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 3161afa33889f1682a1689e76fbcadc397f4b01c..84fea979d482d3d5cacfad4b09237e6345675cad 100644
index f408d6c152d6acabea5ff3e262fe344909046595..ea3b411a78495d0414b1956503b86cbd5f0ed765 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -91,7 +91,7 @@ const fs = require('fs');
const internalFS = require('internal/fs/utils');
@@ -96,6 +96,7 @@ const assert = require('internal/assert');
const fs = require('fs');
const path = require('path');
const { sep } = path;
-const { internalModuleStat } = internalBinding('fs');
const { internalModuleStat } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const { safeGetenv } = internalBinding('credentials');
const {
privateSymbols: {
@@ -182,7 +182,7 @@ function stat(filename) {
@@ -195,7 +196,7 @@ function stat(filename) {
const result = statCache.get(filename);
if (result !== undefined) return result;
if (result !== undefined) { return result; }
}
- const result = internalModuleStat(filename);
+ const result = internalFsBinding.internalModuleStat(filename);
@ -44,19 +43,18 @@ index 3161afa33889f1682a1689e76fbcadc397f4b01c..84fea979d482d3d5cacfad4b09237e63
// 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 c6377faae6f5a827fc9b5c271ebc85f2df2f7177..8143e83ee39a03871642cfd6e7b8671fc4c3454d 100644
index 88c079d10d116107aa34dc9281f64c799c48c0b5..146e2e49dc46c7f5302638f75cca4af548509d77 100644
--- a/lib/internal/modules/package_json_reader.js
+++ b/lib/internal/modules/package_json_reader.js
@@ -8,7 +8,7 @@ const {
const {
@@ -13,6 +13,7 @@ const {
ERR_INVALID_PACKAGE_CONFIG,
} = require('internal/errors').codes;
-const { internalModuleReadJSON } = internalBinding('fs');
const { internalModuleReadJSON } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const { toNamespacedPath } = require('path');
const { resolve, sep, toNamespacedPath } = require('path');
const permission = require('internal/process/permission');
const { kEmptyObject } = require('internal/util');
@@ -48,7 +48,7 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
@@ -53,7 +54,7 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
const {
0: string,
1: containsKeys,

View file

@ -55,10 +55,10 @@ index c9a455be8c395a2f231f56e0a54211466362aa1d..448075e354c760a2dbd1dd763f40b7a6
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
index f08294a26a43923cfb47dde080e42b5cde0803a5..8d48105cb4822dde19982ce1c132f521ff8b27c9 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,
@@ -961,11 +961,8 @@ napi_define_class(napi_env env,
env, p->setter, p->data, &setter_tpl));
}

View file

@ -1,151 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 18 Oct 2023 10:40:34 +0200
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 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 = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
const windowNewlineRegexp = /\r/g;
+function replaceNodeVersion(str) {
+ return str.replaceAll(process.version, '*');
+}
+
function replaceStackTrace(str, replacement = '$1*$7$8\n') {
return str.replace(stackFramesRegexp, replacement);
}
@@ -84,6 +88,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
module.exports = {
assertSnapshot,
getSnapshotPath,
+ replaceNodeVersion,
replaceFullPaths,
replaceStackTrace,
replaceWindowsLineEndings,
diff --git a/test/fixtures/errors/force_colors.snapshot b/test/fixtures/errors/force_colors.snapshot
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: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 *
+ at *
+ at *
+ at *
+ at *
+ 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 b08bcd40cdf26093e158c0bb9ae566c76f2c731e..bf8eacbac479a2bf5698ed29ede648e149f185b5 100644
--- a/test/parallel/test-node-output-errors.mjs
+++ b/test/parallel/test-node-output-errors.mjs
@@ -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, '*');
-}
-
function replaceStackTrace(str) {
return snapshot.replaceStackTrace(str, '$1at *$7\n');
}
+function replaceForceColorsStackTrace(str) {
+ // eslint-disable-next-line no-control-regex
+ return str.replaceAll(/(\[90m\W+)at .*node:.*/g, '$1at *');
+}
+
describe('errors output', { concurrency: true }, () => {
function normalize(str) {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
@@ -35,9 +35,12 @@ describe('errors output', { concurrency: true }, () => {
}
const common = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths);
- const defaultTransform = snapshot.transform(common, normalize, replaceNodeVersion);
- const errTransform = snapshot.transform(common, normalizeNoNumbers, replaceNodeVersion);
- const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion);
+ const defaultTransform = snapshot.transform(common, normalize, snapshot.replaceNodeVersion);
+ const errTransform = snapshot.transform(common, normalizeNoNumbers, snapshot.replaceNodeVersion);
+ const promiseTransform = snapshot.transform(common, replaceStackTrace,
+ normalizeNoNumbers, snapshot.replaceNodeVersion);
+ const forceColorsTransform = snapshot.transform(common, normalize,
+ replaceForceColorsStackTrace, snapshot.replaceNodeVersion);
const tests = [
{ name: 'errors/async_error_eval_cjs.js' },
@@ -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 },
- { skip: skipForceColors, name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } },
+ !skipForceColors ? {
+ name: 'errors/force_colors.js',
+ transform: forceColorsTransform,
+ env: { FORCE_COLOR: 1 }
+ } : null,
];
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 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';
import * as path from 'node:path';
import { describe, it } from 'node:test';
-function replaceNodeVersion(str) {
- return str.replaceAll(process.version, '*');
-}
-
describe('sourcemaps output', { concurrency: true }, () => {
function normalize(str) {
const result = str
@@ -16,7 +12,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
.replaceAll('/Users/bencoe/oss/coffee-script-test', '')
.replaceAll(/\/(\w)/g, '*$1')
.replaceAll('*test*', '*')
- .replaceAll('*fixtures*source-map*', '*');
+ .replaceAll('*fixtures*source-map*', '*')
+ .replaceAll(/(\W+).*node:internal\*modules.*/g, '$1*');
if (common.isWindows) {
const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 1).toLowerCase();
const regex = new RegExp(`${currentDeviceLetter}:/?`, 'gi');
@@ -25,7 +22,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
return result;
}
const defaultTransform = snapshot
- .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion);
+ .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths,
+ normalize, snapshot.replaceNodeVersion);
const tests = [
{ name: 'source-map/output/source_map_disabled_by_api.js' },

View file

@ -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 fe8ddee7cbf05e0d4dbbe970cdc357ec6841390c..1ba65e26d293e9524e6c756b3a66693d46b4bdfd 100644
index fa425fdcfc475ba2d5ba9a2492ea4481914a7cce..840c2f657467ede0e3737ea1aee55e07e39f353a 100644
--- a/test/parallel/parallel.status
+++ b/test/parallel/parallel.status
@@ -7,6 +7,13 @@ prefix parallel
@@ -5,6 +5,13 @@ prefix parallel
# sample-test : PASS,FLAKY
[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 fe8ddee7cbf05e0d4dbbe970cdc357ec6841390c..1ba65e26d293e9524e6c756b3a66693d
[$system==win32]
# https://github.com/nodejs/node/issues/41206
diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status
index 5cefcb95773bedc80bc462e058a11045be176741..33f50be5898754af696468499bcfa8e3c721434d 100644
index a5e2d38ff31aa8b90f3b99783b16cec086b4f30e..b8afe3d88b5af4756663f45fad81105e9b7f0e7e 100644
--- a/test/sequential/sequential.status
+++ b/test/sequential/sequential.status
@@ -7,6 +7,18 @@ prefix sequential

View file

@ -1,5 +1,6 @@
[
"abort/test-abort-backtrace",
"es-module/test-vm-compile-function-lineoffset",
"parallel/test-bootstrap-modules",
"parallel/test-child-process-fork-exec-path",
"parallel/test-code-cache",
@ -21,9 +22,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-http2-https-fallback",
"parallel/test-http2-server-unknown-protocol",
"parallel/test-tls-alpn-server-client",
"parallel/test-https-agent-session-reuse",
"parallel/test-https-options-boolean-check",
"parallel/test-icu-env",

View file

@ -162,8 +162,19 @@ describe('esm', () => {
});
describe('with context isolation', () => {
let badFilePath = '';
beforeEach(async () => {
badFilePath = path.resolve(path.resolve(os.tmpdir(), 'bad-file.badjs'));
await fs.promises.writeFile(badFilePath, 'const foo = "bar";');
});
afterEach(async () => {
await fs.promises.unlink(badFilePath);
});
it('should use nodes esm dynamic loader in the isolated context', async () => {
const [, preloadError] = await loadWindowWithPreload(`await import(${JSON.stringify(hostsUrl)})`, {
const [, preloadError] = await loadWindowWithPreload(`await import(${JSON.stringify((pathToFileURL(badFilePath)))})`, {
nodeIntegration: true,
sandbox: false,
contextIsolation: true