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

Unhandled promise rejection from deferred promise in nested loader #10313

Open
thomaswelton opened this issue Dec 9, 2024 · 1 comment
Open

Comments

@thomaswelton
Copy link

Reproduction

https://github.com/thomaswelton/remix-promise-rejection

Install dependencies and start local dev server

npm install
npm run dev

Navigate to the index page in a browser

open http://localhost:5173/

See that this is the remix starter with a small change. This page incudes a loader that returns a promise, since we're preparing to migrate to RR7 we are not using defer. In your browser you will see a loading message and then once the promise rejects you will see this is picked up by the error component for the Await and will see the text "error message"

This is the expected behaviour for that URL.

Now open the page /fail

open http://localhost:5173/fail

This page uses the same page component as the index page. See the routes.ts file. But this route is nested in a layout. The layout has it's own loader and this issues a redirect response, in the real world this may be a route that is responsible for checking if a user is logged in and issuing a redirect response where required.

System Info

System:
    OS: macOS 15.1.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 178.56 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
    pnpm: 8.9.2 - ~/Library/pnpm/pnpm
    bun: 0.1.2 - ~/.bun/bin/bun
  Browsers:
    Chrome: 131.0.6778.109
    Safari: 18.1.1
    Safari Technology Preview: 18.2
  npmPackages:
    @remix-run/dev: ^2.15.0 => 2.15.0 
    @remix-run/fs-routes: ^2.15.0 => 2.15.0 
    @remix-run/node: ^2.15.0 => 2.15.0 
    @remix-run/react: ^2.15.0 => 2.15.0 
    @remix-run/route-config: ^2.15.0 => 2.15.0 
    @remix-run/serve: ^2.15.0 => 2.15.0 
    vite: ^5.1.0 => 5.4.11

Used Package Manager

npm

Expected Behavior

When opening the page /fail you should be redirected to the index page / and the remix server should not crash

Actual Behavior

You are redirected to the index page. However the remix server has crashed, if you reload the page again you will see the server can not be reached.
The console will show an error from an unhandled promise rejection.

@thomaswelton
Copy link
Author

It is worth noting that if you are using the now deprecated defer this issue does not happen.
Issue discovered while migrating our application and adopting all future flags for RR7

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

1 participant