From c94d99494af977c6dfdf6c737eb34b32b2f04185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 18 Jun 2025 08:48:13 +0200 Subject: [PATCH] deps: V8: cherry-pick 1d7159580156 Original commit message: [explicit-resource-management] Clear isolate internal exception This CL clears the isolate internal exception before rejecting the promise. Bug: 418103036 Change-Id: If3748f7fc4b79b7b5be5009b9fff0d0267541a6f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6594252 Reviewed-by: Shu-yu Guo Commit-Queue: Rezvan Mahdavi Hezaveh Cr-Commit-Position: refs/heads/main@{#100532} Refs: https://github.com/v8/v8/commit/1d71595801567c60eae0e8ae7157c1afd0aedce5 --- common.gypi | 2 +- .../builtins-async-disposable-stack.cc | 7 ++--- ...tion-promise-catch-prediction-expected.txt | 4 +-- .../harmony/regress/regress-418103036.js | 26 +++++++++++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 deps/v8/test/mjsunit/harmony/regress/regress-418103036.js diff --git a/common.gypi b/common.gypi index cbe454d9bb0bed..90f48604f31ddd 100644 --- a/common.gypi +++ b/common.gypi @@ -38,7 +38,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.13', + 'v8_embedder_string': '-node.14', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/builtins/builtins-async-disposable-stack.cc b/deps/v8/src/builtins/builtins-async-disposable-stack.cc index 226184d9d5497a..e1f0ee792c6665 100644 --- a/deps/v8/src/builtins/builtins-async-disposable-stack.cc +++ b/deps/v8/src/builtins/builtins-async-disposable-stack.cc @@ -89,10 +89,6 @@ BUILTIN(AsyncDisposeFromSyncDispose) { kMethod))), isolate); - v8::TryCatch try_catch(reinterpret_cast(isolate)); - try_catch.SetVerbose(false); - try_catch.SetCaptureMessage(false); - MaybeDirectHandle result = Execution::Call(isolate, sync_method, receiver, {}); @@ -107,7 +103,8 @@ BUILTIN(AsyncDisposeFromSyncDispose) { return {}; } // d. IfAbruptRejectPromise(result, promiseCapability). - DCHECK(try_catch.HasCaught()); + isolate->clear_internal_exception(); + isolate->clear_pending_message(); JSPromise::Reject(promise, direct_handle(exception, isolate)); } diff --git a/deps/v8/test/inspector/debugger/break-on-exception-promise-catch-prediction-expected.txt b/deps/v8/test/inspector/debugger/break-on-exception-promise-catch-prediction-expected.txt index a0172dc2494fe5..2e649ddb8fa5b8 100644 --- a/deps/v8/test/inspector/debugger/break-on-exception-promise-catch-prediction-expected.txt +++ b/deps/v8/test/inspector/debugger/break-on-exception-promise-catch-prediction-expected.txt @@ -1133,7 +1133,7 @@ Correctly predicted as caught Running test: testCase > Throwing from throwInAsyncDisposeFormSync, handling with dontHandleAsync -Paused on caught exception +Paused on uncaught promiseRejection [Symbol.dispose] (catch-prediction.js:188:6) throwInAsyncDisposeFormSync (catch-prediction.js:185:18) dontHandleAsync (catch-prediction.js:196:8) @@ -1171,7 +1171,7 @@ Correctly predicted as uncaught Running test: testCase > Throwing from throwInAsyncDisposeFormSync, handling with awaitAndCreateInTry -Paused on caught exception +Paused on caught promiseRejection [Symbol.dispose] (catch-prediction.js:188:6) throwInAsyncDisposeFormSync (catch-prediction.js:185:18) awaitAndCreateInTry (catch-prediction.js:202:10) diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-418103036.js b/deps/v8/test/mjsunit/harmony/regress/regress-418103036.js new file mode 100644 index 00000000000000..537bd9d0a918d3 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/regress/regress-418103036.js @@ -0,0 +1,26 @@ +// Copyright 2025 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --ignore-unhandled-promises + +const obj = { + get f() { + async function f() { + function g() { + throw 1; + } + g[Symbol.dispose] = g; + await using y = g; + } + return f(); + }, +}; + +async function test(obj) { + const ser = d8.serializer.serialize(obj); + const des = d8.serializer.deserialize(ser); + await des; +} + +assertThrowsAsync(test(obj), Error);