Skip to content

Reject non-object iterator results in Array.fromAsync - #1842

Open
theaddonn wants to merge 1 commit into
quickjs-ng:masterfrom
theaddonn:fix-fromasync-next-result
Open

theaddonn wants to merge 1 commit into
quickjs-ng:masterfrom
theaddonn:fix-fromasync-next-result

Conversation

@theaddonn

Copy link
Copy Markdown
Contributor

Fixes #1769

next() returning a primitive now rejects with a TypeError instead of looping forever, and next is read once like the spec says. Touches the same loop as #1596 but doesn't overlap with its close logic.

Array.fromAsync destructured the result of next() without checking
that it was an object. A primitive like 0 has no `done`, so the loop
never ended. The spec throws a TypeError in that case.

It also looked up `next` on every step, while the spec reads it once
when getting the iterator.

Read `next` once, throw on non-object results and regenerate the
precompiled builtin.

Fixes: quickjs-ng#1769

This branch has not been deployed

No deployments
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.

Array.fromAsync does not reject when next() returns a non-object

1 participant