Terminate an async function using TerminateExecution

30 views
Skip to first unread message

Meir Shpilraien

unread,
Jun 27, 2023, 6:57:26 AM6/27/23
to v8-dev
Hey

I notice that when I terminate an async function using TerminateExecution the promise that was suppose to be resolved/rejected as a result of this async function termination are not resolved nor rejected. To demonstrate, look at the following example:

```js
async function foo(){
    await test();
    throw "foo";
}
```

Calling `foo()` will return a promise that will be rejected after the first await returns because we raise an error. But if I change the code to be the following:

```js
async function foo(){
    await test();
    while (true);
}
```

 and assuming the embedder will terminate the execution on the `while (true)` after some timeout (using TerminateExecution), the promise that was returned by calling `foo()` will never be resolved nor rejected.

Am I getting it right or am I missing something? Assuming I am right, any suggestions how to solve it?

Thanks.

Ben Noordhuis

unread,
Jun 28, 2023, 9:45:33 AM6/28/23
to v8-...@googlegroups.com
Your analysis sounds about right.

I don't think there's a workaround. Termination tears down everything,
including the handler code for moving a promise to fulfilled or
rejected state. It's like sending a SIGKILL.
Reply all
Reply to author
Forward
0 new messages