-
Notifications
You must be signed in to change notification settings - Fork 375
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
Fix server functions hanging on edge functions #1255
Conversation
@oscartbeaumont also would be helpful if you can point out the location of the file where |
This is awesome! Thanks for finding this. We should try to get this also upstream in I want to get this ArrayBuffer check in there too. |
Upstreaming this in nksaraf/vinxi#123 |
upstreams Fix server functions hanging on edge functions solidjs/solid-start#1255
Sorry for the lack of detail on the issue, was rushing a bit. I have updated the original issue with a full rundown of what's going on. @nksaraf I was just about to ping you. You raise a good point this should probably be fixed upstream. I am working on a Nitro/h3 PR, I'm honestly not sure who is at fault. Thanks both, am really loving Solid Start! |
I have opened an upstream issue & PR in H3:
I am closing this issue as a Thanks both for your help! |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When you call a server function when Solid Start is deployed on Deno or Vercel Edge Functions the entire function hangs.
Example page at
routes/index.ts
to demonstrate the issue:To test locally you can install Deno and use the following:
The issue is the call to
await request.json()
within handleServerFunction freezes forever causing the request to hang until the function runtime (Eg. Vercel) times out.It's worth noting nothing is special about this call to
request.json()
, it's just the place where the body is used. Any usages of therequest.body
will hang (including.arrayBuffer()
,.text()
, etc).SolidStart calls Vinix
toWebRequest
which in-turn calls H3'sgetRequestWebStream
.Following along with the implementation of the
getRequestWebStream
function:event.web?.request?.body
isundefined
so we go to the next condition,event._requestBody
isundefined
so we go to the next condition,We reach the "finally" condition and create a
ReadableStream
and callevent.node.req.on
to set up listeners to the body.However, none of the
.on(...)
callbacks fire in these Edge environments so the promise hangs and the entire function freezes.I noticed that
event.node.req.body
is anArrayBuffer
so we can bypass theReadableStream
and just use it asbody
property of theRequest
which is what this PR does.This issue is related to:
toWebRequest
to prevent h3 body utils calls from blocking nksaraf/vinxi#118What is the new behavior?
The request returns correctly like it does when run using Node.js.