remix icon indicating copy to clipboard operation
remix copied to clipboard

Single Fetch: Using two equal promises from loader data fails

Open linkvt opened this issue 9 months ago • 0 comments

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 https://github.com/jacob-ebey/turbo-stream/issues/28 . Leaving this issue open as it still affects remix.

linkvt avatar May 19 '24 16:05 linkvt