-
-
Notifications
You must be signed in to change notification settings - Fork 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
Defer not working properly when multiple promises are returned #9154
Comments
We just released a change to the vercel adapter to improve streaming there, could you check again with the latest version of the adapter? |
Just upgraded to You can also check stackblitz+the repo+the demo to verify yourself |
if you surround your page with a |
If I update surround everything with |
Yep. Seems to work fine on |
Seems it's out of sync: the first promise resolve when the second is actually resolved, the second resolve when the third resolve so on and so forth until last two promises which are resolved at the same time. |
Ooh, to add to that, this doesn't occur on client-side navigation where it works just fine. |
My guess at this point is that this has to do with some browser or server behavior where things are buffered and multiple resolved promise updates come in at once |
Could this be a vercel-adapter behavior? |
Digging around, it seems that it's the |
I've tried to use on the response headers. I also see This might be worth another issue given the setHeaders seem to be bugged too when using streaming. @dummdidumm let me know if have to open another issue. P.s. @Smirow How to force the accept-encoding header on the request? By using the server hook? |
@paoloricciuti it's a For the response header, you'll need to pass it a record not a string: |
Yeah i realized after trying that you were setting a
|
That's maybe because the page size is too small and don't get compressed, will have to try with a larger page. Maybe Simon or Rich can get it touch with the competent people at Vercel? |
I think it's because maybe with client side navigation it doesn't stream the entire page but just the data? |
Oh actually during client side navigation the response is sent with |
Hm i've tried to deploy the same app with remix and it seems to work fine. I don't have a stackblitz but you can see the code on github and the live demo at https://test-defer-remix.vercel.app/ So maybe it's not the brotli thing |
Another intresting difference is that remix html comes already with the data if the promise is already resolved (for example the recommended post if you see the rendered html does not have the loading state) |
Yes definitely bizarre, some buffering is going on, can't manage to understand why. |
The chunks get truncated sometimes : test.mov(the end And also seems that
And to add to that, the behavior described above by @paoloricciuti is a bit flaky depending on the build, sometimes the build just work fine (neglecting the script evaluation), sometimes it doesn't. |
This is a limitation in Svelte core, which we plan to address later |
I ran into similar issues with |
It's not supposed to work with |
I don't have a fix for this issue yet but didn't want to leave it uncommented. As far as I can tell browsers batch up content below a certain number of bytes, and when the response is compressed the chunks come in under that threshold. Adding a bunch of junk data (e.g. |
To clarify, I was not using |
Thanks for the comment, just to clarify, the junk data should be inside the actual promise? From your comment seems like it can go inside the await but to me it doesn't make sense |
This is labeled as pkg:adapter-vercel but I suspect this is also happening with Cloudflare. I've noticed that specifically when using Chrome on Cloudflare and returning multiple streaming promises, sometimes just nothing returns. If I use Firefox, it works. If I'm on the local dev server with Firefox or Chrome, it works. I've switched to using a single streaming promise for the main data that I care about (which unfortunately means I have to do a proxied If this issue gets resolved for Vercel and still remains for Cloudflare, I'll open a ticket. But it feels like it could be related. |
Describe the bug
I've tryed the new defer api with vercel edge functions and when a single promise is returned it works as intended. However when you return multiple promises things get's messy quickly.
For example
this configuration correcly wait 2 seconds before showing the page. The recommended shows a sliver of loading state to than resolve immediately however for getComments and getFail the loading state perpetrate until both of them resolve at the same time. When i was trying this at the beginning i saw the same kind of result with only getRecommended + getComments (in this case getRecommended that should already be resolved was persisting in the loading state for a couple of seconds).
2023-02-21.16-42-29.mp4
Reproduction
You can see the live version of this on vercel.
You can see the code on my github repo and edit the code on stackblitz
Logs
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: