Editor sockets: auth-aware reconnect, shared with the analytics view
An expired session failed the /_api/ws/editor handshake exactly like a dead network, so the page/banner editors retried forever — the WS API cannot open the login dialog. reconnect.js gains authReconnect(): on close, probe /_api/settings (dialog-less fetchJson); a 401/403 runs the paskia login flow and reconnects the moment it completes, a declined login holds at a 'session expired' ConnNote, and only transient failures take the paced backoff. A paskia auth-success message from anywhere in the page reconnects a waiting editor at once. AnalyticsView moves from its inline copy of the same flow onto the shared helper.
This commit is contained in:
1 parent
31b56c3e5e
commit
d4add54f10
7 files changed
+136
-71
No files matched your search
+2
-1
@@ -355,7 +355,8 @@ spans less than 24 hours, otherwise `week`.
|
||||
`AnalyticsView.vue` is no longer a full-screen overlay; the `body.analytics-open`
|
||||
page-chrome hiding and `#/analytics/<range>` hash routing have been removed.
|
||||
|
||||
The viewer owns its connection lifecycle. When the socket drops it probes
|
||||
The viewer owns its connection lifecycle (the probe/login mechanics are the
|
||||
shared `authReconnect` in `reconnect.js`, also used by the editor sockets). When the socket drops it probes
|
||||
`/_api/settings` (plain `fetchJson`, never pops a dialog) to tell an expired
|
||||
session from a dead network: a 401/403 runs the paskia login flow instead of
|
||||
retrying (the WS handshake cannot open the login dialog) and the stream
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ In-place page re-rendering shared by the banner/site/structure tabs lives in `sw
|
||||
|
||||
The page and structure tabs share one language selector: `LangSelect.vue` (small flag + dropdown) v-modeled on the shell-wide selection in `editorLang.js` (`''` = primary). While the panel is open that selection overrides the page's normal language preferences: EditorShell calls `swapdoc.setLangOverride`, which pins every `loadPlain` fetch (`?lang=`, the primary by its own code) and pagerite.js's own fetches/prefetches (`pagerite:session-lang`), until the panel closes and the override clears.
|
||||
|
||||
All WebSockets (page/banner editors, analytics view, the pagerite.js activity channel) pace their connections through `reconnect.js`: new sockets are created a staggered slot apart (a page load opens Vite's HMR socket plus several of ours at the same moment, and such bursts — like rapid retries — trip the browser's WebSocket throttling, leaving every socket to the host "pending" for minutes), a watchdog closes sockets stuck CONNECTING so they reschedule instead of hanging forever, and retries follow an exponential backoff with jitter that only a healthy connection resets. While a socket is connecting or waiting to reconnect the panel says so (`ConnNote.vue`), and the CodeMirror editors stay locked until their document arrives (typing before the doc accept would be clobbered by it).
|
||||
All WebSockets (page/banner editors, analytics view, the pagerite.js activity channel) pace their connections through `reconnect.js`: new sockets are created a staggered slot apart (a page load opens Vite's HMR socket plus several of ours at the same moment, and such bursts — like rapid retries — trip the browser's WebSocket throttling, leaving every socket to the host "pending" for minutes), a watchdog closes sockets stuck CONNECTING so they reschedule instead of hanging forever, and retries follow an exponential backoff with jitter that only a healthy connection resets. The admin sockets (`/_api/...`) also close through `authReconnect`: an expired session fails the WS handshake like a dead network but can never open the login dialog from a socket, so the close handler probes `/_api/settings` first — a 401/403 runs the paskia login flow and reconnects the moment it completes (a declined login holds at a "session expired" note; a login anywhere in the page reconnects the panel, via paskia's `auth-success` window message), and only genuine network/server failures take the paced backoff. While a socket is connecting or waiting to reconnect the panel says so (`ConnNote.vue`), and the CodeMirror editors stay locked until their document arrives (typing before the doc accept would be clobbered by it).
|
||||
|
||||
## Saving behavior
|
||||
|
||||
|
||||
Reference in new issue
Block a user