Skip to content

Support async sequence types#278

Merged
domenic merged 20 commits intojsdom:mainfrom
MattiasBuelens:async-sequence
Apr 16, 2026
Merged

Support async sequence types#278
domenic merged 20 commits intojsdom:mainfrom
MattiasBuelens:async-sequence

Conversation

@MattiasBuelens
Copy link
Copy Markdown
Contributor

@MattiasBuelens MattiasBuelens commented Apr 13, 2026

This PR adds support for async sequence types. It was first introduced as async iterable<T> in whatwg/webidl#1397, and later renamed to async_sequence<T> in whatwg/webidl#1500. (Note that this is different from asynchronously iterable declarations, which are already supported since #224.)

The implementation is largely based on the Streams reference implementation (whatwg/streams#1083). Once this PR lands, we will update Streams to use webidl2js's version instead.

@MattiasBuelens
Copy link
Copy Markdown
Contributor Author

@domenic Could you review, or assign someone to review? Thanks. 🙏

Comment thread lib/types.js Outdated
Comment on lines +286 to +287
${name}[Symbol.asyncIterator] !== undefined ||
${name}[Symbol.iterator] !== undefined
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to use GetMethod which throws for non-functions, as per step 11.1.1.1. But for sequences and frozen arrays, we seem to just check for undefined? Should we fix this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fix this, and ideally have some tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this need more tests. This is tricky stuff! 😅

I think I'll also port some of the input validation tests from readable-streams/from.any.js over to this project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with this project not having any runtime tests, but I'm just thinking about if this isn't covered by anything in WPT, then it's good to improve WPT coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look around. The URLSearchParams constructor takes a union with a sequence type, maybe we can add a test there. Or perhaps the IDL harness tests already cover this case?

Copy link
Copy Markdown
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case (just a snapshot test)?

Comment thread lib/types.js Outdated
Comment on lines +286 to +287
${name}[Symbol.asyncIterator] !== undefined ||
${name}[Symbol.iterator] !== undefined
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fix this, and ideally have some tests.

Comment thread lib/types.js Outdated
Comment thread lib/output/utils.js Outdated
Copy link
Copy Markdown
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one question; after hearing back on that, I will merge and release unless you say otherwise.

Comment thread lib/types.js Outdated
@domenic domenic merged commit 09ec607 into jsdom:main Apr 16, 2026
3 checks passed
@MattiasBuelens MattiasBuelens deleted the async-sequence branch April 16, 2026 07:05
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.

2 participants