Skip to content

Commit 542f2a6

Browse files
committed
Fix typo in middleware docs
1 parent 10f6946 commit 542f2a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/how-to/middleware.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const authMiddleware = async ({ request, context }) => {
193193

194194
`next()` is not designed to throw errors under normal conditions, so you generally shouldn't find yourself wrapping `next` in a `try`/`catch`. The responsibility of the `next()` function is to return a `Response` for the current `Request`, so as long as that can be completed, `next()` will return the Response and won't `throw`. Even if a `loader` throws an error, or a component fails to render, React Router already handles those by rendering the nearest `ErrorBoundary`, so a Response is still generated without issue.
195195

196-
This behavior is important to allow middleware patterns such as automatically setting required headers on outgoing responses (i.e., committing a session) from a root middleware. If any error caused that to throw, we'd miss the execution of ancestor middleware son thew way out and those required headers wouldn't be set.
196+
This behavior is important to allow middleware patterns such as automatically setting required headers on outgoing responses (i.e., committing a session) from a root middleware. If any error caused that to throw, we'd miss the execution of ancestor middlewares on the way out and those required headers wouldn't be set.
197197

198198
The only cases in which `next()` _should_ throw are if we fail to generate a Response. There's a few ways in which this could happen:
199199

0 commit comments

Comments
 (0)