Skip to content

Commit 810779a

Browse files
committed
fix(data): re-admit swept tab on ping instead of retiring it
A frozen or background-throttled tab goes silent long enough for sweep to remove its port from replicas. When the tab resumes and pings, the owner saw !replicas.has(port) and answered with retired, permanently killing the store even though the account was still signed in. Now, when a ping arrives from a port not in replicas but the account is still being served, the owner re-adds the port and responds with live, matching the freeze/resume contract.
1 parent a8b6bcb commit 810779a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎packages/octane/src/data/owner.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,16 @@ export function createDataOwner(options: {
390390
let joined: Promise<void> | null = null;
391391
const handle = (message: ToOwner) => {
392392
if (refused.has(port)) return port.postMessage(REFUSED);
393-
// A replica of a retired account is told so, whatever it asks.
394-
if (!replicas.has(port)) return port.postMessage(RETIRED);
393+
if (!replicas.has(port)) {
394+
// Sweep removed a quiet tab from replicas, but the account is still served.
395+
// A ping on resume re-admits it instead of retiring the store.
396+
if (message.t === 'ping' && serving) {
397+
replicas.add(port);
398+
watch(port);
399+
return port.postMessage({ t: 'live' } satisfies ToReplica);
400+
}
401+
return port.postMessage(RETIRED);
402+
}
395403
heard.set(port, hostDateNow());
396404
if (message.t === 'request') request(port, message.id, message.request, message.fresh);
397405
else if (message.t === 'listen') subscribe(port, message.id, message.request);

0 commit comments

Comments
 (0)