You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Throwing primitives in beforeLoad causes the router to stop rendering #4707
Calling throw in a beforeLoad with primitive types such as string or number causes the entire router to hang - preventing the errorComponent from rendering.
This leads to the entire application effectively no longer rendering the router.
changed the title [-]Throwing primitives in beforeLoad causes the router to hang[/-][+]Throwing primitives in beforeLoad causes the router to stop rendering[/+]on Jul 19, 2025
It seems that this issue occurs when err is a primitive type at that line.
Replacing err with an object type does resolve the issue, but I’m not sure if that’s actually necessary.
Do you think it’s common for users to throw primitive values instead of objects?
cc. @schiller-manuel
If needed, I’d be happy to create a PR and work on it.
Do you think it’s common for users to throw primitive values instead of objects?
To answer your question I would pose the following hypothetical: what if the user is not in control of what they are throwing?
Consider the situation in which the user has adopted an RPC library that internally throws errors, and some of those errors are primitive values. They interact with this hypothetical library in a loader, presuming that any errors that occur from the library they are using will be handled by the loader as the docs describe. They are completely unaware that (a) the library they are using is throwing primitives, (b) their application will break because their router will stop rendering as soon as this hypothetical library errors.
Fundamentally, it should not matter "what" the user throws - the router should be resilient to it. The language specification lets you throw primitives, therefore the router should.
Either way, the entire router just stopping rendering when this happens seems unacceptable, even if the team considers throwing primitives in loaders an unacceptable strategy. If this is an intentional decision, it should break in a way that's clear to the consumer and tells them that throwing a primitive is unsupported.
Activity
[-]Throwing primitives in beforeLoad causes the router to hang[/-][+]Throwing primitives in beforeLoad causes the router to stop rendering[/+]leesb971204 commentedon Jul 19, 2025
It seems that this issue occurs when
erris a primitive type at that line.Replacing
errwith anobjecttype does resolve the issue, but I’m not sure if that’s actually necessary.Do you think it’s common for users to throw primitive values instead of objects?
cc. @schiller-manuel
If needed, I’d be happy to create a PR and work on it.
michaelbull commentedon Jul 19, 2025
To answer your question I would pose the following hypothetical: what if the user is not in control of what they are throwing?
Consider the situation in which the user has adopted an RPC library that internally throws errors, and some of those errors are primitive values. They interact with this hypothetical library in a
loader, presuming that any errors that occur from the library they are using will be handled by theloaderas the docs describe. They are completely unaware that (a) the library they are using is throwing primitives, (b) their application will break because their router will stop rendering as soon as this hypothetical library errors.Fundamentally, it should not matter "what" the user throws - the router should be resilient to it. The language specification lets you throw primitives, therefore the router should.
Either way, the entire router just stopping rendering when this happens seems unacceptable, even if the team considers throwing primitives in loaders an unacceptable strategy. If this is an intentional decision, it should break in a way that's clear to the consumer and tells them that throwing a primitive is unsupported.
michaelbull commentedon Jul 19, 2025
@leesb971204 based on the line that you linked, this issue probably relates heavily to the other issue I opened.