[BUG] Running localhost, cannot make request when no internet connection
Describe the bug
I running a refine app on localhost, it should run normal even there's no internet connection
But i cant use the app without internet, i see there is telemetry req error while no connection theni turn off the telemetry through (Refine -> options -> disableTelemery: true). but still not solving the problem, when i see in network console, the requset not start until i connect to internet
Steps To Reproduce
- Install refine
- Setup data and auth provider
- Login
Success! - Logout
- Turn off internet connection
- Retry Login
- Just loading
Not Working! - Check the network console, no request whatsoever is initiated
- Retry login
- Turn on internet connection
- Check the nework console, request is started
- Login
Success
Expected behavior
It should run normal even in no connection
Screenshot
No response
Desktop
OS: Linux Ubuntu Browser: Chrome Latest
Mobile
No response
Additional Context
No response
Hello @ilomon10 how do you expect to login without an internet connection? Can't really see the problem here, as it's expected you can't login or see any data without internet.
Hello @BatuhanW I'm running the project only in local, so all the database and server on local, so why i cant see my own data without internet?
My server is installed on Localhost, my database in localhost, everything in local only there is no effected with outside world
Hey @ilomon10 sorry for the misunderstanding, re-opening the issue, we'll investigate it.
Hey @ilomon10, looks like this is an issue with the @tanstack/query's network mode. You can set it to always or offlineFirst to make it send the requests regardless of the network state.
Thankyou @BatuhanW for reopen the issue 🙇🏻♂️
Thankyou @aliemir now by setting by this, the request now is started without connection. 🎉
<Refine
// ...
options: {
// ...
reactQuery: {
clientConfig: {
defaultOptions: {
mutations: {
networkMode: "offlineFirst" // or replace with "always" to make the request run normally, without connection.
},
},
},
},
}
/>
Hello @ilomon10 would you like to make a contribution by adding this question/answer to our FAQ documentation?
https://github.com/refinedev/refine/blob/master/documentation/docs/guides-concepts/faq/index.md
Sure @BatuhanW Im so excited to contribute.
But im still have type error, when i implement this options
Type error: Type 'string' is not assignable to type 'NetworkMode | undefined'.
options={{
reactQuery: {
clientConfig: {
defaultOptions: {
queries: {
networkMode: "always", // Type error here
},
mutations: {
networkMode: "always", // and here
},
},
},
},
}}