Skip to content
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

Single Fetch: Using two equal promises from loader data fails #9466

Closed
linkvt opened this issue May 19, 2024 · 4 comments · Fixed by #9562
Closed

Single Fetch: Using two equal promises from loader data fails #9466

linkvt opened this issue May 19, 2024 · 4 comments · Fixed by #9562

Comments

@linkvt
Copy link

linkvt commented May 19, 2024

Reproduction

https://stackblitz.com/edit/remix-run-remix-hgnfzj?file=app%2Froutes%2F_index.tsx

System Info

not relevant, see StackBlitz environment

Used Package Manager

npm

Expected Behavior

When using single fetch and thus turbo-stream, we should be able to return two promises resolving the same value.
This occurred to me when returning the count of items in two tables to display in a dashboard which happened to be equal.

I'm opening the issue in here as I do not know, if this was caused by an error in remix or turbo-stream.

Thanks!

Actual Behavior

turbo-stream throws an error while unflattening the responses.

According to the stack trace it seems to be this check whether the array is empty: https://github.com/jacob-ebey/turbo-stream/blob/a72f7a76e393cf43b265036521d519c22f2c3c08/src/unflatten.ts#L35

The data returned by remix looked like this:

[...{"31":32,"33":34,"35":36},"promiseA",["P",32],"somethingStatic",0,"promiseB",["P",36]]
P32:[1]
P36:[]

Edit: I decided to dig a bit deeper and could recreate this issue in turbo-stream, see jacob-ebey/turbo-stream#28 . Leaving this issue open as it still affects remix.

@linkvt
Copy link
Author

linkvt commented May 31, 2024

Just tested it with turbo-stream 2.1.0 by adding an overwrite like this to my package.json:

  "overrides": {
    "turbo-stream": "2.1.0"
  }

Works as expected 👍

@brophdawg11 brophdawg11 linked a pull request Jun 5, 2024 that will close this issue
@brophdawg11
Copy link
Contributor

This should be resolved by #9562 and available in the next release

@brophdawg11 brophdawg11 added the awaiting release This issue has been fixed and will be released soon label Jun 13, 2024
Copy link
Contributor

🤖 Hello there,

We just published version 2.10.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 2.10.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue has been fixed and will be released soon label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants