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
Errors thrown in beforeLoad have properties inserted by the router #4708
In our application, we throw errors in beforeLoad that are strongly typed objects with rich diagnostic information, such as error codes and messages.
I have observed that the router is mutating our errors before they hit the errorComponent, inserting its own routerCode field.
Consider an example where our rich error object already includes a routerCode field; the router is now overwriting our value that we constructed in our business logic.
It also raises a strong concern about whatever future fields the router decides to start inserting/overwriting on the error object. Given these seem to be internal implementation details, there's no way for consumers to be aware that this is happening unless they observe it, as I did.
Throw an object in a route's beforeLoad, and observe the routerCode property is either added/overwritten on the object you throw. Potentially other fields are overwritten, however routerCode is the only one I've observed.
Expected behavior
Include these error codes in some other fashion - without polluting the original error that was thrown in business logic.
Activity
leesb971204 commentedon Jul 19, 2025
This is also related to #4707 .