feat(realtime): long polling for app-wide events behind proxies

When a proxy lets neither WebSocket nor SSE through, the app opens a
poll connection: the server buffers its events (an SSEClient without a
stream), each GET waits up to 25 s, and room joins work like for SSE.
Tasks and lists now update live there too, and note sync takes its
notifications from it instead of a second long poll. Idle connections
close after two minutes. The profile shows such a connection as limited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-11-02 11:50:27 +01:00
1 parent c19d8fd03e
commit 2b7356d043
16 files changed
+369 -20

No files matched your search

+2
View File
@@ -641,6 +641,8 @@ export class DocSyncEngine {
}
private channel(): SyncChannel {
// The app-wide long polling brings the notifications: same channel as the note's own long polling
if (this.pushKind === 'poll') return 'longpoll';
if (this.pushKind !== 'none') return this.pushKind;
if (this.longPollRunning && !this.longPollBroken) return 'longpoll';
return 'interval';
+3 -2
View File
@@ -1,8 +1,9 @@
// Push notifications for note sync: the server sends DOC_SEQ into the note's room whenever the note, its
// leases or its presence change. Delivery uses the app-wide realtime connection (WebSocket, else SSE).
// leases or its presence change. Delivery uses the app-wide realtime connection (WebSocket, else SSE, else
// long polling).
import { createRealtimeConnection, getRealtimeTransport, isRealtimeConnected } from '../api';
export type PushKind = 'ws' | 'sse' | 'none';
export type PushKind = 'ws' | 'sse' | 'poll' | 'none';
export interface PushChannel {
/** Calls onPoke for changes of docId and onStatus whenever the channel goes up or down. */