Skip to content
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

OnlineManager subscription doesn’t execute when going offline #1654

Closed
kripod opened this issue Jan 15, 2021 · 1 comment · Fixed by #1656
Closed

OnlineManager subscription doesn’t execute when going offline #1654

kripod opened this issue Jan 15, 2021 · 1 comment · Fixed by #1656
Labels

Comments

@kripod
Copy link
Contributor

kripod commented Jan 15, 2021

Describe the bug
I just noticed that the built-in onlineManager instance emits a notification only when going online, but not when going offline.

To Reproduce

React.useEffect(
  () =>
    onlineManager.subscribe(() => {
      // Logs only `{ online: true }`, no matter what happens
      // Cannot detect going offline
      console.log({ online: onlineManager.isOnline() });
    }),
  [],
);

Expected behavior
OnlineManager should listen to the "offline" event of browsers, besides just "online".

Desktop (please complete the following information):

  • OS: macOS 11.1
  • Browser: Firefox
  • Version: 84.0.2 (64-bit)

Additional context
It seems like the default listener in OnlineManager doesn’t listen for "offline" events: https://github.com/tannerlinsley/react-query/blob/ac342e237ae9fab6759f2d7be616662da6c16225/src/core/onlineManager.ts#L51-L63

@tannerlinsley
Copy link
Collaborator

🎉 This issue has been resolved in version 3.5.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants