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

Incorrect error message when server loader throws an error and clientLoader is present #8300

Closed
justinwaite opened this issue Dec 15, 2023 · 6 comments · Fixed by #8304
Closed
Labels
bug Something isn't working feat:routing

Comments

@justinwaite
Copy link
Contributor

justinwaite commented Dec 15, 2023

Reproduction

https://stackblitz.com/edit/remix-run-remix-uyj9e9?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.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm
  npmPackages:
    @remix-run/css-bundle: 2.4.0 => 2.4.0 
    @remix-run/dev: 2.4.0 => 2.4.0 
    @remix-run/node: 2.4.0 => 2.4.0 
    @remix-run/react: 2.4.0 => 2.4.0 
    @remix-run/serve: 2.4.0 => 2.4.0

Used Package Manager

npm

Expected Behavior

When an error is thrown in a server loader, I expect to be able to capture that error message and display it to the user in an error boundary. The error message in the reproduction that should be displayed is:

This is an error message that should render in the boundary.

Actual Behavior

I get an initial flash of the expected error message, but quickly overridden by:

You defined a loader for route "routes/_index" but didn't return anything from your `loader` function. Please return a value or `null`.

If you remove the clientLoader, this behavior goes away.

Note: if you are looking at the stackblitz and see the "correct" error message, just refresh the app and most of the time you will see the "incorrect" error message as described above.

@justinwaite
Copy link
Contributor Author

After some further investigation, it seems the problem is that calling serverLoader in the clientLoader function returns undefined in the event of loader throwing an error. Then undefined gets returned from clientLoader. I would expect that if loader throws an error, then calling serverLoader would likewise throw an error instead of undefined.

@brophdawg11
Copy link
Contributor

Thanks for the reproduction and investigation!

@brophdawg11 brophdawg11 added bug Something isn't working feat:routing and removed bug:unverified labels Dec 15, 2023
@brophdawg11
Copy link
Contributor

Resolved by #8304 and will be in the next release 👍

@brophdawg11 brophdawg11 removed their assignment Dec 15, 2023
@brophdawg11 brophdawg11 added the awaiting release This issue has been fixed and will be released soon label Dec 15, 2023
@justinwaite
Copy link
Contributor Author

@brophdawg11 you guys are lightning fast. Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 2.4.1-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.4.1 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 Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat:routing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants