TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
8.19k stars 646 forks source link

A rejected promise in <Await> in a notFoundComponent is not caught by the `defaultErrorComponent` #2256

Open lo1tuma opened 2 months ago

lo1tuma commented 2 months ago

Which project does this relate to?

Router

Describe the bug

I‘m using <Await> to fetch some data in a notFoundComponent. When using renderToPipeableStream() I can see the following object has been thrown and not caught by an error boundary:

{
  data: { data: { data: [Object], __isServerError: true } },
  __isServerError: true
}

Your Example Website or App

https://stackblitz.com/edit/github-yk78pg-wpq5bb

Steps to Reproduce the Bug or Issue

Expected behavior

I would expect:

  1. the defaultErrorComponent being invoked with the rejected promise from <Await />
  2. to get an actual instance of Error instead of the serialized server error object

Screenshots or Videos

No response

Platform

Additional context

No response

SeanCassiere commented 2 months ago

Please attach a valid minimal reproduction showing off the issue in question. You can fork our Stackblitz starter to make the setup process easier - https://stackblitz.com/github/tanstack/router/tree/main/examples/react/quickstart-file-based

lo1tuma commented 2 months ago

This issue only happens during server-side-rendering. So I’ve used basic-ssr-file-based as an example. See https://stackblitz.com/edit/github-5vsdzx

What has been changed:

Steps to reproduce:

SeanCassiere commented 2 months ago

An <Await> with a Promise is not something typically found in a notFoundComponent.

@lo1tuma what's your expectation as to what's supposed to happen here?

@tannerlinsley what's Start's desired expectation here?

lo1tuma commented 2 months ago

An <Await> with a Promise is not something typically found in a notFoundComponent.

See also this discussion I’m basically looking for a unified way to load data in a notFoundComponent.

@lo1tuma what's your expectation as to what's supposed to happen here?

My expectation would be that the error is getting caught and instead of rendering the notFoundComponent the errorComponent should get rendered.