-
The paused state persists intermittently. I expect the query to be executed again when the network is reconnected. However, it remains paused intermittently, and remains paused on refresh and incognito mode. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
can you show a reproduction? |
Beta Was this translation helpful? Give feedback.
-
There seems to be a bug in onLine in Chromium-based browsers. Please check the address below How about changing the method to check the online status by using the online and offline events? In the case of swr, I checked the article that it was solved through the event listener because of the problem. |
Beta Was this translation helpful? Give feedback.
-
I ask something about listening to the online / offline events. In onlineManager.ts, The setup method of the OnlineManager class puts a callback function that receives a boolean value of online as a parameter when online / offline events of the window occur. But the callback function doesn't actually receive the online value as a parameter, so when does this.setOnline(online) statement get executed? It seems that only the this.onOnline() statement will always be executed. For example, if onlineManager.setOnline(false) is executed 3 seconds after entering a web page where the network is online, and then the network is disconnected and reconnected, the online event will occur, but the online value of onlineManager is still false, so the api call will not run. Isn't it correct to change onlineManager's setup function as follows? this.setup = (onOnline) => {
if (!isServer && window.addEventListener) {
const listener = (event: 'online' | 'offline') => {
this.setOnline(event === 'online') // it is needed, isnt' it?
onOnline()
}
// Listen to online
onlineEvents.forEach((event) => {
window.addEventListener(event, listener, false)
})
return () => {
// Be sure to unsubscribe if a new handler is set
onlineEvents.forEach((event) => {
window.removeEventListener(event, listener)
})
}
}
return
} |
Beta Was this translation helpful? Give feedback.
we also listen to the online / offline events. The difference is that
swr
tries to work around that bug by always initializing withtrue
, which is somewhat wrong. If you are really offline, it would show up as wrongfully online, which is the same issue, just the other way around