Skip to content

Commit eda1344

Browse files
committed
fix(data): bump protocol version and clear serving on failed sign-in
Bump PROTOCOL from 1 to 2 so tabs built against the pre-fencing SharedWorker protocol never share a worker with fencing-enabled tabs. Without this, an older tab connects to a fencing owner, never sends hello, and every request is answered retired — which it cannot handle. Clear serving when decide() rejects so the next hello for the same account retries IndexedDB instead of reusing the rejected promise and immediately retiring every subsequent tab.
1 parent b7292b7 commit eda1344

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎examples/shelf/e2e/shelf.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ async function dataWorker(keeper: Page, namespace: string) {
416416
type: 'module',
417417
name,
418418
});
419-
}, `octane-data:1:${namespace}:ada`);
419+
}, `octane-data:2:${namespace}:ada`);
420420
const cdp = await keeper.context().browser()!.newBrowserCDPSession();
421421
let targetId = '';
422422
await expect

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ export function createDataOwner(options: {
190190
replicas.add(port);
191191
port.postMessage({ t: 'live' } satisfies ToReplica);
192192
},
193-
() => port.postMessage(RETIRED),
193+
() => {
194+
if (serving === current) serving = null;
195+
port.postMessage(RETIRED);
196+
},
194197
);
195198
}
196199

@@ -570,7 +573,7 @@ export function createReplica(
570573
}
571574

572575
/** The owner protocol's version, in the worker's name, so a tab on another protocol never shares it. */
573-
const PROTOCOL = 1;
576+
const PROTOCOL = 2;
574577
const RETIRED: ToReplica = { t: 'retired' };
575578
/** How long a tab waits for its owner to confirm a sign-out before asking again. */
576579
const SIGN_OUT_RETRY_MS = 5_000;

‎packages/octane/tests/data-owner.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ describe('octane/data in a SharedWorker', () => {
423423
try {
424424
expect(sharedOwner('ada')).toBe(port);
425425
expect(constructed).toEqual([
426-
['/_octane/data-worker.js', { type: 'module', name: 'octane-data:1:ada' }],
426+
['/_octane/data-worker.js', { type: 'module', name: 'octane-data:2:ada' }],
427427
]);
428428
vi.stubGlobal(
429429
'SharedWorker',

0 commit comments

Comments
 (0)