Skip to content

Commit 7f85014

Browse files
authored
Remove instanceof check from isRouteErrorResponse (#9930)
1 parent 15ad8d5 commit 7f85014

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.changeset/silver-snails-destroy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": patch
3+
---
4+
5+
Remove instanceof check from isRouteErrorResponse to avoid bundling issues on the server

packages/router/utils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,8 +1395,14 @@ export class ErrorResponse {
13951395

13961396
/**
13971397
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
1398-
* Response throw from an action/loader
1398+
* Response thrown from an action/loader
13991399
*/
1400-
export function isRouteErrorResponse(e: any): e is ErrorResponse {
1401-
return e instanceof ErrorResponse;
1400+
export function isRouteErrorResponse(error: any): error is ErrorResponse {
1401+
return (
1402+
error != null &&
1403+
typeof error.status === "number" &&
1404+
typeof error.statusText === "string" &&
1405+
typeof error.internal === "boolean" &&
1406+
"data" in error
1407+
);
14021408
}

0 commit comments

Comments
 (0)