-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve fetch() #522
Comments
Does |
@benjamingr It should follow the DOM semantics - we'll have a helper to turn it into a deno reader. |
@ry that effectively means shipping ReadableStream and ReadableStreamDefaultReader though and two stream abstractions out of the box. |
@benjamingr True - but I think we should hold to the promise of DOM compatibility. |
Fetch has been improved a lot since the creation of this issue - the major missing piece is now streaming response body. I will probably work on this soon - but in case someone is interested - here's a bit of an outline of how it should be done.
If you're interested in working on this, be sure to sync with me first over email or gitter. |
@ry talking to Jake and the |
We've implemented streaming bodies in superfly/fly.rs and it makes a pretty significant difference in performance/memory usage. We have a "body mixin" which both We use the very good (and very new), typed, @stardazed/streams package for our I'm happy to port some of these changes over and adapt them. One thing I'm not so sure about is we added a concept of Another difference, not sure if it matters, is: we don't keep track of "data" passed raw into v8. We assume it's consumed right away and GC the buffer in rust with a callback. |
Just a note that streaming response bodies should be registered in the resources table - so they can use the read() and write() ops and interop with other “streams” (aka Reader / Writer) |
We could add them in there for sure, but Polling to read requires 1 extra message per chunk (ask to read, get a read chunk), while pushing is just 1 message (the read chunk). Normally I don't think it would matter that much, but passing more messages for such frequent messages might be too heavy. For things like We also push from V8 to write back http response bodies. Once a stream is "done", we immediately delete it from the JS Map, so memory will be freed pretty quickly by V8's GC if nothing is holding onto it outside the map. If the user holds onto the response or the request, they'll be able to still read from the body. There's a fair chance I don't know enough, but that technique seems to work for us at the moment. |
|
Node streams have a pull mode though for ever now which is what's typically used in real applications. That said Node streams are a mess and pretty much no one likes them :) |
Depends on fetch landing (#512) which will happen in v0.1
For v0.2:
deno/js/fetch.ts
Line 49 in 168d92f
The text was updated successfully, but these errors were encountered: