@@ -160,17 +160,17 @@ function currentDeltaFragment(event: CurrentDelta) {
160160}
161161
162162export function resumeStreamAfterPageShow ( _event : PageTransitionEvent , start : ( ) => unknown ) {
163- // Açık fetch() event stream bfcache'i engeller → pageshow'da persisted
164- // çoğunlukla false gelir, gate'li start hiç çalışmazdı (#47258).
165- // Gate kaldırıldı : start() idempotent (started ise mevcut run'ı döner ).
163+ // An open fetch() event stream blocks bfcache, so `persisted` is mostly
164+ // false on pageshow and the gated start() never ran (#47258).
165+ // Gate removed : start() is idempotent (returns the current run when started ).
166166 start ( )
167167}
168168
169- // Server her 10sn'de `server.heartbeat` gönderir (global.ts/event.ts) —
170- // sağlıklı stream'de chunk aralığı ~10-15sn'yi geçmez. Arka planda ölen
171- // (half-open) stream ne hata verir ne veri üretir; `start()` idempotent
172- // guard'a takılıp no-op döndüğü için reconnect de tetiklenmez (#47258'in
173- // devamı: Android'de pageshow çoğu zaman hiç ateşlenmez ).
169+ // The server sends `server.heartbeat` every 10s (global.ts/event.ts), so a
170+ // healthy stream never goes ~10-15s without a chunk. A stream that dies in
171+ // the background (half-open) neither errors nor yields data, and the
172+ // idempotent `start()` guard degrades to a no-op, so no reconnect fires
173+ // either (follow-up to #47258: on Android, pageshow often never fires ).
174174export const STREAM_STALL_MS = 30_000
175175
176176export function shouldForceReconnect ( opts : {
@@ -180,15 +180,15 @@ export function shouldForceReconnect(opts: {
180180} ) : boolean {
181181 if ( opts . visible === false ) return false
182182 const now = opts . now ?? Date . now ( )
183- // Hiç chunk gelmediyse (bağlantı kurulurken background'a düşüldü vb.)
184- // görünür sekmeye dönüşte zorla — abort zararsız, loop 250ms sonra dener .
183+ // No chunk ever arrived (e.g. backgrounded while connecting): force on
184+ // return to a visible tab — abort is harmless, the loop retries in 250ms .
185185 if ( opts . lastChunkAt === undefined ) return true
186186 return now - opts . lastChunkAt > STREAM_STALL_MS
187187}
188188
189- // Stall bekçisi: proot'ta (Android lifecycle olmadan) test edilebilen
190- // ince katman. Gerçek DOM wiring'i (visibilitychange → onVisible,
191- // online → onOnline) altta .
189+ // Stall guard: thin layer that stays testable in proot (no Android
190+ // lifecycle). The real DOM wiring (visibilitychange → onVisible,
191+ // online → onOnline) lives below .
192192export function createStreamStallGuard ( opts : { onStall : ( ) => void } ) {
193193 let lastChunkAt : number | undefined
194194 return {
@@ -201,8 +201,8 @@ export function createStreamStallGuard(opts: { onStall: () => void }) {
201201 opts . onStall ( )
202202 return true
203203 } ,
204- // Ağ geri geldiğinde: görünürlükten bağımsız stall kontrolü .
205- // `online` sahte de gelebilir — sağlıklı stream'e dokunulmaz .
204+ // On network return: stall check independent of visibility .
205+ // `online` can be spurious — a healthy stream is left alone .
206206 onOnline ( now : number = Date . now ( ) ) : boolean {
207207 if ( ! shouldForceReconnect ( { lastChunkAt, now, visible : true } ) ) return false
208208 opts . onStall ( )
@@ -299,10 +299,10 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
299299
300300 let streamErrorLogged = false
301301 const stallGuard = createStreamStallGuard ( { onStall : ( ) => attempt ?. abort ( ) } )
302- // In-stream watchdog (openchamber event-pipeline parity): hiçbir lifecycle
303- // event'i (visibility/pageshow/online) ateşlenmese bile half-open stream
304- // STREAM_STALL_MS'tan fazla yaşayamaz. Her chunk'ta resetlenir, süre
305- // dolunca mevcut denemeyi abortlar — loop 250ms sonra reconnect dener .
302+ // In-stream watchdog (openchamber event-pipeline parity): a half-open
303+ // stream cannot outlive STREAM_STALL_MS even when no lifecycle event
304+ // (visibility/pageshow/online) ever fires. Reset on every chunk; on
305+ // expiry it aborts the current attempt — the loop reconnects in 250ms .
306306 let stallTimer : ReturnType < typeof setTimeout > | undefined
307307 const clearStallTimer = ( ) => {
308308 if ( stallTimer === undefined ) return
@@ -321,8 +321,8 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
321321 let run : Promise < void > | undefined
322322 let started = false
323323 let generation = 0
324- // offline'ta stop() edildiyse online'da start() ile devam et; pagehide
325- // ile duran stream'i online diriltmesin diye ayrı bayrak tutulur .
324+ // If stop()ped while offline, resume with start() on online; a separate
325+ // flag so online doesn't resurrect a stream stopped via pagehide .
326326 let offlineStopped = false
327327
328328 const start = ( ) => {
@@ -335,8 +335,8 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
335335 // oxlint-disable-next-line no-unmodified-loop-condition -- `started` is set to false by stop() which also aborts; both flags are checked to allow graceful exit
336336 while ( ! abort . signal . aborted && started && generation === active ) {
337337 attempt = new AbortController ( )
338- // Bağlantı kurulurken takılmaya karşı da kurulu başla (ilk chunk
339- // gelmeden asılı kalan subscribe 30sn'de abort olur, loop dener ).
338+ // Arm while connecting too, against a stuck subscribe (one hanging
339+ // before the first chunk aborts after STREAM_STALL_MS, the loop retries ).
340340 armStallTimer ( )
341341 const onAbort = ( ) => {
342342 attempt ?. abort ( )
@@ -400,17 +400,17 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
400400 onMount ( ( ) => {
401401 makeEventListener ( window , "pagehide" , stop )
402402 makeEventListener ( window , "pageshow" , ( event ) => resumeStreamAfterPageShow ( event , start ) )
403- // Android'de arka plan → ön plan dönüşünde pageshow çoğunlukla
404- // ateşlenmez; ölü (half-open) stream `started` guard'a takılıp
405- // sessizce asılı kalır. Görünürlüğe dönüşte stall varsa mevcut
406- // denemeyi abortla — loop'un doğal 250ms reconnect yoluna girer .
403+ // On Android, background → foreground usually fires no pageshow; the
404+ // dead (half-open) stream stays silently stuck on the `started` guard.
405+ // On return to visibility, abort the current attempt when stalled —
406+ // the loop then takes its natural 250ms reconnect path .
407407 makeEventListener ( document , "visibilitychange" , ( ) => {
408408 if ( ! started ) return
409409 stallGuard . onVisible ( document . visibilityState )
410410 } )
411- // Ağ kesilince 250ms retry spin'ine girme — loop'u durdur, timer'ı
412- // temizle. Ağ dönünce: offline'ta durduysa `start()` ile devam et
413- // ( idempotent), çalışıyorsa sadece stall varsa abortla .
411+ // On network loss don't spin the 250ms retry loop — stop the loop and
412+ // clear the timer. On return: if stopped while offline, continue with
413+ // `start()` ( idempotent); if running, abort only when stalled .
414414 makeEventListener ( window , "offline" , ( ) => {
415415 if ( ! started ) return
416416 offlineStopped = true
0 commit comments