Surface thrown response headers to ancestor boundaries #6425
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a gap in the API currently where you cannot access headers from child-route-thrown-responses because we only run
headers()
from "renderable" matches (which means root down to the boundary). So if youthrow new Response()
from/parent/child
and catch it in/parent
- you have no way to send any child headers back from the/parent
headers()
function.This PR adds a new
errorHeaders
parameter toheaders()
that holds the headers from any thrown Response triggering the error boundary.If the route that throws the response is also the boundary route, then
errorHeaders
will be the same as what's already passed asloaderHeaders
/actionHeaders
.We also only expose the
errorHeaders
to the leaf renderable matchheaders()
function to avoid duplicating the header value throughparentHeaders
.Closes #5356