Support sync and async iterables with Response/Request#5476
Conversation
This comment has been minimized.
This comment has been minimized.
petebacondarwin
left a comment
There was a problem hiding this comment.
Approved for typings changes.
ded0063 to
ae576ac
Compare
|
Moving this back to draft. It's going to require a compatibility flag which is going to require some additional work. |
Do we really need a compat flag here? |
|
Does the new behavior only apply to nodejs_compat - I don't immediately see that in the code |
|
Yes, a compat flag is needed. The key issue is that stuff like
We have tests that do exactly this. Specifically, we have tests that are passing an Array to
This really doesn't matter. Even as a bug fix it would require a compat flag.
No, it's being enabled generally, not just for |
|
Testing Node.js further, it looks like they cheat around the issue by actually not supporting sync iterables. So actually, I think we may be able to safely enable that case but there's still an ambiguity that probably still requires a compat flag... If an obj the user is currently passing is has a |
ae576ac to
a9ef841
Compare
This comment was marked as outdated.
This comment was marked as outdated.
a9ef841 to
0cb1779
Compare
guybedford
left a comment
There was a problem hiding this comment.
Why is there no WPT coverage diff on this PR? I would have expected we'd see an improvement, or does it need to be turned on for the WPT tests? Can we do that here?
|
It's a node.js extension. As far as I know it's not supported by spec. |
|
Given this is a Node.js compat feature, could we put it behind |
We've had people request it independently of nodejs_compat. I was planning to imply it on when nodejs_compat is on but also wanted the ability to switch it on/off independently and have it available without nodejs_compat. |
0cb1779 to
ff1b1a5
Compare
|
Right, and I know you mentioned this before but just to reiterate - the only risky compat case seems to be |
|
Well, in that case they can simply disable the compat flag to switch it off. Not sure what other special casing would be necessary? |
|
Yeah agreed, it seems like it should be fine, but there's options if we hit any compat questions down the line. I mean specifically separating treatment of |
|
Thanks @jasnell 🎉 |
While passing sync/async iterables to
RequestandResponseare not part of the standard, Node.js implements it and we've been asked to also.Note that this will NOT give us 100% compat with Node.js on this feature yet. Node.js supports writing strings to the response, e.g.
yield 'foo';while we still require the values to beArrayBufferorArrayBufferView. We will be supporting strings as part of a different change that'll take a bit longer to land.