Skip to content

Compiled async generator remains open after an uncaught delegated throw rejection #3655

Open

Description

@nickna

A compiled async generator remains resumable after an uncaught rejection from a delegated synchronous iterator's throw request.

const iterable = {
    [Symbol.iterator]() {
        return { next() { return { value: 1, done: false }; } };
    }
};
async function* uncaught() { yield* iterable; }
async function main() {
    const generator = uncaught();
    console.log((await generator.next()).value);
    try { await generator.throw('boom'); }
    catch (error) { console.log('rejected'); }
    console.log('closed', (await generator.next()).done);
}
main();

On 3cdf0f08d (compiler unchanged from merged PR #3650), a saved assembly built with --no-tsconfig --noLib --compile source.ts --standalone --verify passes IL verification and prints:

1
rejected
closed false

Node v22.23.2 prints 1, rejected, closed true. After the rejected request exits the generator without a local handler, later next() calls should resolve with done: true.

Found while checking #3646. The missing-throw rejection value is tracked by #3646; this report concerns the separate persistent generator completion state after that rejection.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions