Skip to content

fix: only say "offline" when the editor cannot reach the server (#417) - #442

Merged
vibhavkatre merged 1 commit into
mainfrom
fix/offline-status-toast-417
Aug 13, 2026
Merged

fix: only say "offline" when the editor cannot reach the server (#417)#442
vibhavkatre merged 1 commit into
mainfrom
fix/offline-status-toast-417

Conversation

@vibhavkatre

Copy link
Copy Markdown
Collaborator

Closes #417.

The bug

onSaveError treated every failure that was not a revision conflict as a lost
connection. It started a five second countdown, then put "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, 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
Response to an HTTP error, so that case is now told apart from a request that
never completed, and it reports "Save failed" as before. Only the second case
counts as a connectivity problem. navigator.onLine then separates a dead
network from a server that is simply unreachable:

  • browser offline: "You're offline"
  • browser online, request never landed: "Can't reach the server"

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 the
in-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.

frozenReason and clearFrozen went with it. Both were write-only once the
reconnect handler stopped reading them.

Tests

useAutosave.test.js gains the classification: a 500 must not claim offline, a
bare fetch failure must, and a dead network reports itself as a dead network. The
offline event 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.

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.
@vibhavkatre
vibhavkatre merged commit 01addb8 into main Aug 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Offline Status and Offline Toast Behavior

2 participants