-
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
Properly handle in-flight network errors on _data requests #6783
Conversation
🦋 Changeset detectedLatest commit: 4321b36 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
init.headers = headers; | ||
return new Response(body, init); | ||
} | ||
|
||
// Mark all successful responses with a header so we can identify in-flight | ||
// network errors that are missing this header | ||
response.headers.set("X-Remix-Response", "yes"); |
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.
Instead of having to remember to do this in each success code path,. should we instead do this higher up? I kept it here to colocate it with the setting of the error/catch headers but it feels potentially error-prone in the future:
function requestHandler() {
...
if (url.searchParams.has("_data")) {
response = await handleDataRequestRR(...);
if (!response.headers.has('X-Remix-Error') && !response.headers.has('X-Remix-Catch')) {
response.headers.set('X-Remix-Response', 'yes');
}
...
}
...
}
@jacob-ebey raised a good question around whether a CDN would cache this header or not. I think it probably depends on the CDN - I would hope CDN's aren't caching 4xx/5xx responses. But technically, yeah if a if a CDN cached a user-returned 4xx/5xx response and did not cache the |
Spoke with @mjackson and we agreed that CDN's (1) should not generally be caching 4xx/5xx responses, but (2) if they are configured to - they should be caching the headers along with it, so we do not expect the above scenario to be an issue. |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
If we make a
?_data
fetch
and it never actually reaches the Remix server, and instead we get a 4xx/5xx response back from a CDN/Proxy/Load Balancer, etc., then we currently incorrectly think it's a returned response from aloader
/action
since it's perfectly valid to:This PR adds an
X-Remix-Response: yes
header to successful responses for?_data
requests so we can differentiate responses that reached the Remix server from those that did not - and we can treat CDN/Proxy errors as real errors and surface them to theErrorBoundary
.Closes #5418