Comments (14)
Thanks @cdock1029, we're removing make-fetch-happen right away, will close this issue as soon as the new version is pushed.
from remix.
If you want to get unblocked, don't return the fetch directly, unwrap it and send your own:
const { json } = require("@remix-run/react");
module.exports = async () => {
let res = await fetch(url);
let body = await res.json();
return json(body)
}
https://remix.run/dashboard/docs/loader#json-helper
from remix.
It is intermittent though, but seems to happen when clicking around quickly. I also checked at it is not just a development issue, it also happens on the production build. BTW it is nice that the prod build is just like development, this will save a lot of head scratching in the future.
from remix.
Every time the error occurs, it's a 304 and the "request has no response data available".
Some combination of clearing cache and reloading server avoids the error for a while. Maybe it's a chrome issue.. not sure.
from remix.
Hey @cdock1029!
Can you post your loader code?
from remix.
loaders/routes/team.ts
module.exports = async () => {
return fetch(`https://api.github.com/orgs/reacttraining/members`);
};
from remix.
Hard to reproduce.. not seeing it for a while now, but previously was getting it every request. Would have ignored if other use didn't post exact same error.
Not fully aware of http / browser interaction.. does 304 mean browser should have the data? I logged the loader function and it had data from fetch and returned it.
Always it was an empty response when it failed (thus the JSON message I assume)
from remix.
Im seeing this too. It seems to happen when _remix/data
responds with a 304 and theres no json body.
from remix.
I wonder if this can be related to blindly passing along response headers from github to the client. For instance if a 304 is returned from github this could be out of sync if the response caches are origin specific.
from remix.
FWIW, changing the loader to pass through only relevant headers and not mirror the response code seems to solve the issue. Maybe returning fetch(...)
directly is just a little too cute.
module.exports = async ({ params }) => {
const res = await fetch(`https://api.github.com/users/${params.member}`);
return new Response(res.body, {
status: 200,
statusText: 'OK',
headers: {
'Content-Type': res.headers.get('content-type'),
'Cache-Control': res.headers.get('cache-control')
}
})
};
from remix.
I'm kinda of wondering how the server's cache could ever be in sync with the browser's cache to make 304's work?
If github returns not modified, and our server passes that back to browser, what if the browser doesn't have the data? Also, the browser didn't pass any E-tag to github... our server did right?
I think we'd have to somehow sync the "request" passed from browser into the fetch on the server for the caching to be consistent...
This is hard to reproduce because the fetch to github on the server doesn't often return a 304 it seems. But i did get it to reproduce if you load the data route first, then go back to "Home". Then clear the browser cache, and fetch the data route again.
If the status is a 304 at that point, the error will trigger because I think the browser doesn't have the data referred to by the E-tag sent by the server.
Just thinking out loud, I'm certainly not very well versed in this stuff, so could be off base.
This might be relevant, but in our case we would seem to want this behavior if we wanted to pull from the browser cache, though as described this doesn't seem to work now
edit:
Something like this maybe.. now I see 304's on client side.
module.exports = async ({ context: { req } }: any) => {
return fetch('https://api.github.com/orgs/reacttraining/members', {
headers: {
'If-None-Match': req.get('If-None-Match'),
},
})
}
from remix.
I'm getting the same issue, posted in Discord and here's a short video. For me it's happening pretty consistently when hitting the back button.
from remix.
Since make-fetch-happen
uses a server-side cache, if If-None-Match
isn't provided in the the fetch
initialization, fetch
will use the server cache to define this itself.
We can see how this gets out of sync. Populate the server cache by making some requests in the browser. Then open an incognito window. This client will now not be passing any e-tag because it has no data in its cache. But when the loader makes a fetch call, it will look in its own cache and forward an e-tag. If the external API returns 304
, this response is then passed back to browser, telling it to redirect the to its cache which doesn't have the data.
from remix.
fixed in remix-run/remix#0.6.1
from remix.
Related Issues (20)
- Vite: custom tsconfig paths are not respected when I pass getLoadContext to the Cloudflare Proxy plugin HOT 5
- Unhandled error from promise in loader causes Remix to crash HOT 8
- A hybrid EJS – CommonJS module is being imported as CommonJS HOT 2
- Uncaught SyntaxError: The requested module '/app/root.tsx? does not provide an export named 'Layout' (at root.tsx) HOT 8
- Relative path does not resolve correctly with flat file routes with redirect HOT 5
- [vite] Files shared between Remix and Express are loaded twice HOT 2
- `useRouteLoaderData("root")` returns `undefined` in root's `ErrorBoundary`/`Layout` when non-existent page is loaded right away. HOT 10
- `TypeError: Can't modify immutable headers.` in handleDataRequestRR (Cloudflare Pages) HOT 2
- When use custom routes, pages use `root.tsx` Layout only and skip own by prefix pattern HOT 1
- Vulnerability detected in library Braces
- [Vite] Remix probably serves malformed response HOT 4
- Node Fetch: Cannot cancel a stream that already has a reader HOT 3
- Random preloads added for images HOT 1
- `assetsDir` not properly resolved when using `basename` when using Wrangler HOT 1
- Splat Routes that would have been prioritized can be overridden by Dynamic Segments. HOT 7
- remix hydration error when using gtag
- [Vite] [Cloudflare] dev server start failed with http_proxy environment variable
- Onclick handler not working in remix and problem installing tailwindcss HOT 5
- MetaFunction data type not inferred from clientLoader HOT 3
- Application Error: failed to execute insertBefore on Node HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remix.