-
Notifications
You must be signed in to change notification settings - Fork 223
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
toWebRequest
starts reading request body eagerly, and we should make it lazy (start reading when a body function is called)
#570
Comments
After reading the spec for the Fetch API, I think that the approach of a getter will not work. There it basically states that |
I feel like it's probably possibly to dynamically define that property as want to achieve compliance with that standard and still be lazy, since this is an adapter layer I think it's worth it to be optimal to the usage patterns that our platforms need |
Checking impl, We might provide a second new option to |
I will create a repro, though generally thinking once user makes a toWebRequest call, are the other body reading functions kinda invalid? Maybe we should throw an error there |
@pi0 solidjs/solid-start#1165 this is a good reproduction of the issue. [FROM THE ISSUE] Current behavior 😯 Expected behavior 🤔 Steps to reproduce 🕹 Go to codesandbox.io/p/devbox/solid-start-middleware-for-server-with-promise-session-not-working-6kz3tm?file=%2Fsrc%2Fmiddleware.ts%3A31%2C57 |
I would appreciate a minimal (h3-only) reproduction in order to follow this up 🙏🏼 |
Right now
toWebRequest
callsgetRequestWebStream
eagerly, which starts reading the request body (to make it into a readable stream). I think we should do this lazily so the user can read the body differently if needed. We can make it lazy a few ways, make thebody
property into a getter that lazily creates the ReadableStream. And thejson()
,text()
helpers will then rely on that.h3/src/utils/request.ts
Lines 157 to 168 in a94a4fc
The text was updated successfully, but these errors were encountered: