-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix native fetch immutable headers issue #9693
Conversation
🦋 Changeset detectedLatest commit: 9d6bbf9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 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 |
parentId: "root", | ||
index: true, | ||
loader() { | ||
return fetch(`https://remix.run/docs/en/main?_data=root`); |
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 don't really want to keep this here but the only way to replicate this issue was to actually get a legit Response
from a fetch
call which is why we didn't run into this before. Thoughts on how to best prevent a regression in this area without spamming our prod server?
@@ -360,12 +360,12 @@ async function handleDataRequest( | |||
|
|||
// 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.
If this response is a direct undici
fetch
Response
, then the headers are immutable and we can't change them. I didn't want to clone the response in 100% of scenarios since this isn't an issue with return json()
and alternatives, so I am only cloning if this operation throws the immutable
error
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
So, I think this is the same issue here: #9212 I've updated to 2.10.2, and this does restore the previous behavior, with the exception that returning the error response results in a framework exception (that I suppose would be caught by an ErrorBoundary). Shouldn't this only happen if we
This code before would return as loader/action data, but now it does not 😢 |
I do not see that behavior. Please open a ne wissue with a reporduction and we can take a look. But my quick attempt works as expected: // routes/page.tsx
import { useLoaderData } from "@remix-run/react";
export async function loader() {
const response = await fetch("http://localhost:5173/resource");
if (!response.ok) {
return response;
}
return { message: "from loader" };
}
export default function Comp() {
const data = useLoaderData();
return <p>data: {data?.message}</p>;
}
// routes/resource.tyx
import { json } from "@remix-run/node";
export function loader() {
return json({ message: "from resource route" }, { status: 500 });
} |
Nevermind, it is in a loader where I'm seeing this behavior. I'll investigate my code further and see if I can figure it out. Thanks! |
Fixes #9691