Skip to content

Commit 5344e4b

Browse files
committed
Add note to docs on middleware error before next
1 parent d1c272a commit 5344e4b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/how-to/middleware.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@ export const middleware: Route.MiddlewareFunction[] = [
487487
];
488488
```
489489

490+
Which `ErrorBoundary` is rendered will differ based on whether your middleware threw _before_ or _after_ calling then `next()` function. If it throws _after_ then it will bubble up from the throwing route just like a normal loader error because we've already run the loaders and have the appropriate `loaderData` to render in the route components. However, if an error is thrown _before_ calling `next()`, then we haven't called any loaders yet and there is no `loaderData` available. When this happens, we must bubble up to the highest route with a `loader` and start looking for an `ErrorBoundary` there. We cannot render any route components at that level or below without any `loaderData`.
491+
490492
## Changes to `getLoadContext`/`AppLoadContext`
491493

492494
<docs-info>This only applies if you are using a custom server and a custom `getLoadContext` function</docs-info>

0 commit comments

Comments
 (0)