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

Deferred values seem broken in single fetch #10467

Open
lifeiscontent opened this issue Feb 6, 2025 · 5 comments
Open

Deferred values seem broken in single fetch #10467

lifeiscontent opened this issue Feb 6, 2025 · 5 comments

Comments

@lifeiscontent
Copy link
Contributor

Reproduction

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

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @remix-run/dev: * => 2.15.3 
    @remix-run/node: * => 2.15.3 
    @remix-run/react: * => 2.15.3 
    @remix-run/serve: * => 2.15.3 
    vite: ^5.1.0 => 5.4.14

Used Package Manager

npm

Expected Behavior

expect to be able to use the value from useAsyncError

Actual Behavior

never consistently returns the error value.

@brookslybrand
Copy link
Contributor

You have to throw an error. In this example a string is thrown, not an error

@lifeiscontent
Copy link
Contributor Author

@brookslybrand I also tried a Response, and that doesn't work either

@lifeiscontent
Copy link
Contributor Author

@brookslybrand the docs also say value which means it doesn't need to be an error. https://api.reactrouter.com/v7/functions/react_router.useAsyncError.html

@brookslybrand brookslybrand reopened this Feb 6, 2025
@lifeiscontent
Copy link
Contributor Author

here's a similar repro of this working without single fetch:

https://stackblitz.com/edit/remix-run-remix-msywtrm6?file=app%2Froutes%2F_index.tsx,vite.config.ts (just turn on single fetch to see it behave inconsistently)

1 caveat which personally makes this API a little rough to use is not being able to have it already consume error responses or primitive values

@brookslybrand
Copy link
Contributor

This seems to be a duplicate issue of react-router #12676

I'm not sure whether it was intended or not to throw arbitrary non-error values from deferred promises before single fetch.

As for sending a Response, I don't know if that's a great value to return, since the response for the data/document has already been sent. This is further data that's streaming in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants