keepalive
with body being async generator
#2372
Replies: 2 comments
-
It's part of the fetch spec, I'm sure someone can give you an answer if you asked on their GitHub or their chat. Note that the spec doesn't typically allow any async iterable, so this is part of the spec dealing with how ReadableStreams are handled. |
Beta Was this translation helpful? Give feedback.
-
Ok I think I can answer my own question: Lines 1330 to 1334 in a3a437e That is nothing except possibly throw more errors! I guess this error related to async generators is to remain semantically true to the spec that the request could not be sent if the JavaScript context that the generator function runs inside was no longer around? However I don't see how that differs from any other type of body, seeing as it is possible for From MDN,
Correct me if I'm wrong, but an API whose only purpose is to throw an error in an edge-case of body type seems like a bit of a trap. I'd prefer to see it ignored completely rather than throw an error in this case don't you think? Furthermore it would be beneficial to have some documenation in the type definitions stating that |
Beta Was this translation helpful? Give feedback.
-
undici/lib/fetch/body.js
Lines 189 to 193 in 8050ec0
It seems that if
RequestInit.body
is an async generator, thenRequestInit.keepalive
is not allowed and we get an error. Why is this? It makes it hard to usekeepalive
without knowing ahead of time what type of body will be given.Also
keepalive
is not documented here at all... what does it do inundici
's implementation of fetch? I'm guessing it has nothing to do with keeping the TCP connection/socket alive between requests?Beta Was this translation helpful? Give feedback.
All reactions