mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 15:04:43 +02:00
[explicit-resource-management] Fix async disposal
This CL fixes the async disposal from sync methods that return a promise. The result of calling `symbol.dispose` should not be used to resolve the outer promise. Bug: 42203814 Change-Id: I4c4573035b74b06ad78e2810e3f132301954c048 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6291492 Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Rezvan Mahdavi Hezaveh <rezvan@chromium.org> Cr-Commit-Position: refs/heads/main@{#98898}
This commit is contained in:
parent
44d71fbe7d
commit
15e602780c
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2025 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: Fix async disposal from sync method returning a promise.
|
||||||
|
includes: [asyncHelpers.js, compareArray.js]
|
||||||
|
flags: [async]
|
||||||
|
features: [explicit-resource-management]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
asyncTest(async function() {
|
||||||
|
let values = [];
|
||||||
|
|
||||||
|
async function TestAsyncDisposalWithSyncMethodReturningAPromise() {
|
||||||
|
let stack = new AsyncDisposableStack();
|
||||||
|
const neverResolves = Promise.withResolvers().promise;
|
||||||
|
stack.use({
|
||||||
|
[Symbol.dispose]() {
|
||||||
|
return neverResolves
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await stack.disposeAsync();
|
||||||
|
values.push(42);
|
||||||
|
|
||||||
|
await using x = {[Symbol.dispose]: () => neverResolves};
|
||||||
|
values.push(43);
|
||||||
|
};
|
||||||
|
|
||||||
|
await TestAsyncDisposalWithSyncMethodReturningAPromise();
|
||||||
|
|
||||||
|
assert.compareArray(values, [42, 43]);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user