diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-26 12:44:50 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-26 12:44:50 +0200 |
| commit | 5dcf3066a2be83d5422ea176e39b413c4769bcf8 (patch) | |
| tree | ef0d8f649f0873d6b788f9dacceb8d470a0f0603 /poc | |
| parent | 03c2c0deaebee645bd61dfb8d4e7bd9d942e6408 (diff) | |
| download | meshbay-5dcf3066a2be83d5422ea176e39b413c4769bcf8.tar.gz | |
fix(transport): wake a backing-off reconnect on visibilitychange, fix listener leak
Confirmed live by trace: during a screen lock, every reconnect attempt
failed with "Failed to fetch" (the browser grants no network access to a
locked/backgrounded tab, no code can change that) — expected. But the
backoff timer itself was also throttled while locked: an attempt scheduled
30s out took ~3 minutes of wall clock to fire, because a backgrounded tab's
timers run only when the OS lets them. Recovery after unlocking was
correspondingly delayed rather than prompt.
Fix: an always-on visibilitychange listener (separate from the diagnostic
one, and unlike it not gated on trace mode) resolves the current backoff
wait immediately once the page is visible again, instead of waiting out
whatever of it is left. The actual reconnect this enables is fast (~1.2s in
the trace that showed the "Failed to fetch" run) — the wait was the
throttled part.
Also fixes a real bug the same trace exposed: connect() re-arms the
diagnostic visibility listener and health-ping interval on every attempt
without ever removing the previous instance's — 8 failed attempts during
one lock left 8 duplicate `visibility` trace lines per real event, and (more
than a cosmetic issue) 8 concurrent health-ping intervals once reconnected.
Diffstat (limited to 'poc')
0 files changed, 0 insertions, 0 deletions