fix: only say "offline" when the editor cannot reach the server (#417) - #442
Merged
Conversation
Any save failure that was not a revision conflict started a five second
countdown to "You're offline — reconnect to keep editing." in the header. A
500 from save_diagram, a revoked permission and a dropped Wi-Fi all arrived
there as the same sentence, so people were told they had no connection while
they were online.
A server that answers, with any status, is reachable. That case now reports
"Save failed" and nothing else. A request that never completes is the only one
that counts as a connectivity problem, and the browser's own verdict separates
a dead network ("You're offline") from an unreachable server ("Can't reach the
server").
The notice moved out of the header and into a toast, said once per episode.
Losing the network no longer freezes the editor either: drawing continues,
every edit still reaches IndexedDB, and the retry rides the next debounce
instead of waiting for a reload. A stale revision still freezes, because that
one needs a reload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #417.
The bug
onSaveErrortreated every failure that was not a revision conflict as a lostconnection. It started a five second countdown, then put "You're offline —
reconnect to keep editing." in the header. A 500 from
save_diagram, a revokedpermission and a dropped Wi-Fi all arrived there as the same sentence, which is
why the editor told people they were offline while they were online.
The fix
A server that answers, with any status, is reachable. frappe-ui attaches the
Responseto an HTTP error, so that case is now told apart from a request thatnever completed, and it reports "Save failed" as before. Only the second case
counts as a connectivity problem.
navigator.onLinethen separates a deadnetwork from a server that is simply unreachable:
The notice is a toast, said once per episode and cleared when a save lands or
the browser reconnects. The header no longer carries it.
Losing the network no longer freezes the editor
The freeze also stopped
scheduleSave, so while it was up no edit reached thein-memory pending document or IndexedDB. Anything drawn during an outage was
kept only if the user happened to edit again after reconnecting. Drawing now
continues through an outage, every edit still reaches IndexedDB, and the retry
rides the next debounce. A stale revision still freezes: that one needs a reload.
frozenReasonandclearFrozenwent with it. Both were write-only once thereconnect handler stopped reading them.
Tests
useAutosave.test.jsgains the classification: a 500 must not claim offline, abare fetch failure must, and a dead network reports itself as a dead network. The
offlineevent is covered too, so the toast does not wait for a save to fail.1164 unit tests pass. Verified live in the editor: the toast reads "You're
offline" and the header stays clean.