Skip to content

Nested context from async beforeLoad can be unexpected undefined. causing errors in child routes #6068

@demitrin

Description

@demitrin

Which project does this relate to?

Router

Describe the bug

Using parent route context that is computed from an async beforeLoad function can cause the context to resolve in a child route's async beforeLoad to undefined. This causes unexpected errors because the context type does not expect undefined to be a valid value.

A version of this issue was previously reported and considered solved (#4998 (comment)).

Your Example Website or App

https://stackblitz.com/edit/github-pv1k3znv?file=src%2Froutes%2Fposts.%24postId.tsx

Steps to Reproduce the Bug or Issue

refresh example on url https://mklilqjgazgithub-g3em--3000--365214aa.local-credentialless.webcontainer.io/posts/1

Expected behavior

I would expect that context is stable when going down the route chain from root -> parent -> child, even for async beforeLoad logic.

Screenshots or Videos

No response

Platform

  • Router: v1.140.5
  • OS: macOs
  • Browser: Chrome
  • Browser Version: latest
  • Bundler: vite
  • Bundler Version: latest

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions