-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update single fetch headers approach to use response stub API #9142
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
712d0fd
TEMP WORK
brophdawg11 045731d
Wire up responseStub interface
brophdawg11 392ab0f
Switch to proxied headers approach
brophdawg11 dae36b9
Handle redirects
brophdawg11 b838164
Bump router and fix bump router script
brophdawg11 9231eb6
Fix TS errors
brophdawg11 d3bba24
Fix a few E2E tests
brophdawg11 309a498
Few more E2E fixes
brophdawg11 9e87eb5
Fix boundary tests and handle defer headers
brophdawg11 3668700
shakes fist at TS
brophdawg11 91275cf
chore: use proxy for response stub cache to simplify call site use (#…
jacob-ebey 6bfd9f3
Add changeset
brophdawg11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
"@remix-run/server-runtime": patch | ||
--- | ||
|
||
Add `ResponseStub` header interface for single fetch and deprecate the `headers` export | ||
|
||
- The `headers` export is no longer used when single fetch is enabled | ||
- `loader`/`action` functions now receive a mutable `response` parameter | ||
- `type ResponseStub = { status: numbers | undefined, headers: Headers }` | ||
- To alter the status of a response, set the `status` field directly | ||
- `response.status = 201` | ||
- To set headers on the Response, you may use: | ||
- `response.headers.set` | ||
- `response.headers.append` | ||
- `response.headers.delete` | ||
- Each `loader`/`action`receives it's own unique `response` instance so you cannot see what other `loader`/`action` functions have set (which would be subject to race conditions) | ||
- If all status codes are unset or have values <200, the deepest status code will be used for the HTTP response | ||
- If any status codes are set to a value >=300, the highest >=300 value will be used for the HTTP Response | ||
- Remix tracks header operations and will replay them in order (action if present, then loaders top-down) after all handlers have completed on a fresh `Headers` instance that will be applied to the HTTP Response | ||
- `headers.set` on any child handler will overwrite values from parent handlers | ||
- `headers.append` can be used to set the same header from both a parent and child handler | ||
- `headers.delete` can be used to delete a value set by a parent handler, but not a value set from a child handler | ||
- Because single fetch supports naked object returns, and you no longer need to return a `Response` instance to set status/headers, the `json`/`redirect`/`redirectDocument`/`defer` utilities are considered deprecated when using Single Fetch | ||
- You may still continue returning normal `Response` instances and they'll apply status codes in the same way, and will apply all headers via `headers.set` - overwriting any same-named header values from parents | ||
- If you need to append, you will need to switch from returning a `Response` instance to using the new `response` parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brophdawg11 , I totally understand that
json
anddefer
can be considered deprecated but I'm surprised forredirect
andredirectDocument
, especiallyredirectDocument
which relies on a Remix custom header, ie an implementation that should be ignored in user land I think. So what will be the recommended way to redirect?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, specially because I usually throw redirect responses, to stop execution, will that stop to work?