Notice a new build without being told
Checking only on a 401 was not automatic, just deferred. It needs the tab to make a request, so one left open and idle went on running the old build until somebody touched it -- which is exactly the thing that cannot be relied on. The obvious signal turned out to be the wrong one, and testing is what showed it. A deploy kills the EventSource behind /api/events, which looks like the perfect cue, except it arrives while the container is still being replaced: the check that follows cannot reach the server, fails, and is never retried. Waiting for the stream to come back instead does not work either, because the session died with the old container, so the reconnect is answered with a 401 and never reaches "connected" at all. The drop is still watched, since it costs nothing and sometimes lands late enough to be useful, but nothing depends on it. What the guarantee rests on is a slow poll while the tab is visible, plus a check when it becomes visible again. Neither cares what the stream is doing or whether anyone is at the keyboard. /api/health touches nothing upstream, so a minute between checks costs one small request per open tab. Reloading is now something that happens to people rather than something they ask for, which makes it able to destroy work. A compose window holds text that has not reached the server, and after a deploy it cannot be saved at all -- the session went with the container. Reloading would be the difference between signing in again and pressing send, and losing what was written. So anything holding such state can say so, and compose does; the tab stays on the old build until the draft is dealt with, and catches up on the next check afterwards.
This commit is contained in:
1 parent
a3dc7e017c
commit
fedd6ed161
4 files changed
+185
-2
No files matched your search
@@ -10,6 +10,7 @@ import { useMail, FULL_PROPS, BODY_PROPS } from "./mail";
|
||||
import { ensureScheduledMailbox, useScheduled } from "./scheduled";
|
||||
import { formatScheduleTime, holdUntil } from "@/lib/schedule";
|
||||
import { settings } from "./settings";
|
||||
import { holdReloadWhile } from "@/lib/staleBuild";
|
||||
|
||||
export interface ComposeAttachment {
|
||||
id: string;
|
||||
@@ -807,3 +808,8 @@ export function draftFromMailto(url: string): Partial<Draft> {
|
||||
...(body ? { html: body, text: m.body } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
// A deploy can reload this tab out from under whoever is writing. Text that has
|
||||
// not been autosaved lives only here, and once the session is gone it cannot be
|
||||
// saved at all -- so say so, and let them sign in and send it instead.
|
||||
holdReloadWhile(() => useCompose.getState().drafts.some((d) => d.dirty));
|
||||
Reference in new issue
Block a user