From a1281480b03705c3c64afa142056cd04d8427599 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 31 Aug 2020 20:05:36 -0700 Subject: [PATCH] Remove redundant promise rejection callback https://github.com/nodejs/node/pull/34387 --- patches/node/.patches | 1 - ..._preventing_setpromiserejectcallback.patch | 50 ------------------- shell/common/node_bindings.cc | 4 +- 3 files changed, 2 insertions(+), 53 deletions(-) delete mode 100644 patches/node/fix_allow_preventing_setpromiserejectcallback.patch diff --git a/patches/node/.patches b/patches/node/.patches index 9a5c41a22e6e5..d802ef05a8934 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -27,7 +27,6 @@ fix_use_crypto_impls_for_compat.patch fix_window_c-ares_incompatibilities.patch fix_comment_out_incompatible_crypto_modules.patch update_tests_after_increasing_typed_array_size.patch -fix_allow_preventing_setpromiserejectcallback.patch lib_use_non-symbols_in_isurlinstance_check.patch feat_add_implementation_of_v8_platform_postjob.patch fix_enable_tls_renegotiation.patch diff --git a/patches/node/fix_allow_preventing_setpromiserejectcallback.patch b/patches/node/fix_allow_preventing_setpromiserejectcallback.patch deleted file mode 100644 index 96b35eb676ab0..0000000000000 --- a/patches/node/fix_allow_preventing_setpromiserejectcallback.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -Date: Wed, 15 Jul 2020 18:43:32 -0700 -Subject: fix: allow preventing SetPromiseRejectCallback - -We do not want to use the promise rejection callback that Node.js uses, -because it does not send PromiseRejectionEvents to the global script context. -We need to use the one Blink already provides, and so we need to -slightly augment IsolateSettings to allow for that. - -diff --git a/src/api/environment.cc b/src/api/environment.cc -index 2bfba8a011c2b902932e6b1714bbb55b945cd96d..28851b8a8f8bdd6dec0f54c62f79fd75a3be08ed 100644 ---- a/src/api/environment.cc -+++ b/src/api/environment.cc -@@ -235,9 +235,11 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) { - s.allow_wasm_code_generation_callback : AllowWasmCodeGenerationCallback; - isolate->SetAllowWasmCodeGenerationCallback(allow_wasm_codegen_cb); - -- auto* promise_reject_cb = s.promise_reject_callback ? -- s.promise_reject_callback : task_queue::PromiseRejectCallback; -- isolate->SetPromiseRejectCallback(promise_reject_cb); -+ if (s.flags & SHOULD_SET_PROMISE_REJECTION_CALLBACK) { -+ auto* promise_reject_cb = s.promise_reject_callback ? -+ s.promise_reject_callback : task_queue::PromiseRejectCallback; -+ isolate->SetPromiseRejectCallback(promise_reject_cb); -+ } - - if (s.flags & DETAILED_SOURCE_POSITIONS_FOR_PROFILING) - v8::CpuProfiler::UseDetailedSourcePositionsForProfiling(isolate); -diff --git a/src/node.h b/src/node.h -index b9b11b4331bd3ae4a87f65758ee09af25222e19a..60ecc3bd3499c23b297bc11e7f052aede20520c2 100644 ---- a/src/node.h -+++ b/src/node.h -@@ -304,12 +304,14 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { - - enum IsolateSettingsFlags { - MESSAGE_LISTENER_WITH_ERROR_LEVEL = 1 << 0, -- DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1 -+ DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1, -+ SHOULD_SET_PROMISE_REJECTION_CALLBACK = 1 << 2 - }; - - struct IsolateSettings { - uint64_t flags = MESSAGE_LISTENER_WITH_ERROR_LEVEL | -- DETAILED_SOURCE_POSITIONS_FOR_PROFILING; -+ DETAILED_SOURCE_POSITIONS_FOR_PROFILING | -+ SHOULD_SET_PROMISE_REJECTION_CALLBACK; - v8::MicrotasksPolicy policy = v8::MicrotasksPolicy::kExplicit; - - // Error handling callbacks diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 9eb11f7d88f7d..9a4d17f0f20d3 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -450,8 +450,8 @@ node::Environment* NodeBindings::CreateEnvironment( // We do not want to use the promise rejection callback that Node.js uses, // because it does not send PromiseRejectionEvents to the global script // context. We need to use the one Blink already provides. - is.flags &= - ~node::IsolateSettingsFlags::SHOULD_SET_PROMISE_REJECTION_CALLBACK; + is.flags |= + node::IsolateSettingsFlags::SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK; } // This needs to be called before the inspector is initialized.