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: Can't return empty Map or Set from loader (turbo-stream issue?) #9495

Closed
caprica opened this issue May 27, 2024 · 4 comments · Fixed by #9562
Closed

Single Fetch: Can't return empty Map or Set from loader (turbo-stream issue?) #9495

caprica opened this issue May 27, 2024 · 4 comments · Fixed by #9562

Comments

@caprica
Copy link

caprica commented May 27, 2024

Reproduction

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

In this stackblitz, it will work initially because the Map/Set contains data, but comment out the indicated line of code that adds data to to the map or set and it will fail with an exception in the browser.

If you refresh the stackblitz with empty Map/Set it will initially render correctly, but then the page will clear, with console errors in the browser.

System Info

System:
    OS: Linux 5.15 Linux Mint 21.3 (Virginia)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Memory: 22.22 GB / 31.30 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    npm: 10.8.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
  Browsers:
    Chrome: 123.0.6312.105
  npmPackages:
    @remix-run/dev: ^2.9.2 => 2.9.2 
    @remix-run/express: ^2.9.2 => 2.9.2 
    @remix-run/node: ^2.9.2 => 2.9.2 
    @remix-run/react: ^2.9.2 => 2.9.2 
    @remix-run/testing: 2.9.2 => 2.9.2 
    vite: ^5.2.11 => 5.2.11

Used Package Manager

npm

Expected Behavior

To successfully return empty Map and Set from loader and decode via useLoaderData.

Actual Behavior

Unable to return empty Map or Set from a loader, would have to null it out instead.

Exception thrown in browser:

Error: Unable to decode turbo-stream response from URL: https://whatever
    at fetchAndDecode (https://whatever/node_modules/.vite/deps/@remix-run_react.js?v=6dff2301:2679:11)

Problem is likely in turbo-stream dependency used by Remix, I raised this issue a few weeks ago, trying to get more visibility here now: jacob-ebey/turbo-stream#26

@caprica
Copy link
Author

caprica commented Jun 3, 2024

There is a change for this in turbo-stream release 2.1.0.

@brophdawg11 brophdawg11 linked a pull request Jun 5, 2024 that will close this issue
@brophdawg11 brophdawg11 changed the title Can't return empty Map or Set from loader when using Single Fetch (turbo-stream issue?) Single Fetch: Can't return empty Map or Set from loader (turbo-stream issue?) Jun 5, 2024
@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.

4 participants