refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] Running localhost, cannot make request when no internet connection

Open ilomon10 opened this issue 2 years ago • 3 comments

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

  1. Install refine
  2. Setup data and auth provider
  3. Login Success!
  4. Logout
  5. Turn off internet connection
  6. Retry Login
  7. Just loading Not Working!
  8. Check the network console, no request whatsoever is initiated
  9. Retry login
  10. Turn on internet connection
  11. Check the nework console, request is started
  12. 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

ilomon10 avatar Jan 14 '24 05:01 ilomon10

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.

BatuhanW avatar Jan 15 '24 08:01 BatuhanW

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

ilomon10 avatar Jan 17 '24 02:01 ilomon10

Hey @ilomon10 sorry for the misunderstanding, re-opening the issue, we'll investigate it.

BatuhanW avatar Jan 17 '24 13:01 BatuhanW

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.

  • Check out the Network Mode docs from the @tanstack/query here
  • Check out the <Refine /> component config to update it globally here

aliemir avatar Jan 18 '24 06:01 aliemir

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.
          },
        },
      },
    },
  }
/>

ilomon10 avatar Jan 18 '24 07:01 ilomon10

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

BatuhanW avatar Jan 22 '24 14:01 BatuhanW

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
        },
      },
    },
  },
}}

ilomon10 avatar Jan 23 '24 02:01 ilomon10