Skip to content

[RFC] emit_async_iterator_return_close() added for async of#4

Draft
sadhbh-c0d3 wants to merge 1 commit into
masterfrom
emit_async_iterator_return_close
Draft

[RFC] emit_async_iterator_return_close() added for async of#4
sadhbh-c0d3 wants to merge 1 commit into
masterfrom
emit_async_iterator_return_close

Conversation

@sadhbh-c0d3

@sadhbh-c0d3 sadhbh-c0d3 commented May 18, 2026

Copy link
Copy Markdown
Collaborator
  • Added emit_async_iterator_return_close()

This is to fix discrepancy between Quickjs and V8 behaviour when Async Iterator is finalised.

Below is the test that can be applied to confirm behaviour without this change (after this change QuickJS behaviour is identical to V8).

let flag = false;
const it = {
  i: 0,
  async next() { return this.i++ ? { done: true } : { value: 1, done: false }; },
  async return() {
    await 0;
    flag = true;
    return { done: true };
  },
  [Symbol.asyncIterator]() { return this; }
};

(async () => {
  for await (const x of it) break;
  console.log(flag);                     //< QuickJS: false, Node: true
  await Promise.resolve();
  asyncIteratorCloseObserved.push(flag); //< QuickJS: true, Node: true
})();

@sadhbh-c0d3 sadhbh-c0d3 changed the title emit_async_iterator_return_close() added for async of [RFC] emit_async_iterator_return_close() added for async of May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant