Skip to content

Commit 39070c2

Browse files
sabjornclaude
andcommitted
Drop the service worker warm-up now that listeners register in time
document_start pinged the worker with { contentScriptQuery: 'warmup' } so it would be awake by the time document_end connected. Nothing ever handled that message - there is no listener for it anywhere - so it always rejected and the rejection was swallowed. Booting the worker was the whole point. That was a workaround for listeners registering after an await, which is fixed: every backend now registers during the worker's initial synchronous run, so the connection that wakes it is routed rather than dropped. The warm-up no longer has a job. Measured against a worker left idle for 60s, twice, with the warm-up gone: the theme still applies pre-paint, stored preview marks come back 252-253ms after load, and a preview click writes through and persists. Both the read and write paths survive a cold wake with nothing pre-booting the worker. Refs #301 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 60e2426 commit 39070c2

2 files changed

Lines changed: 3 additions & 16 deletions

File tree

‎src/document_start.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import { createLogger } from './logger';
22

33
const log = createLogger();
44

5-
const warmServiceWorker = (): void => {
6-
chrome.runtime
7-
.sendMessage({ contentScriptQuery: 'warmup' })
8-
.catch(() => log.debug('Warm-up message went unanswered; the worker still booted'));
9-
};
10-
115
const captureUrlCartParam = (): void => {
126
if (!window.location.search.includes('bes_cart')) return;
137

@@ -30,5 +24,4 @@ const captureUrlCartParam = (): void => {
3024
window.location.replace(newUrl);
3125
};
3226

33-
warmServiceWorker();
3427
captureUrlCartParam();

‎test/document_start.test.ts‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,17 @@ const runDocumentStart = async () => {
3535
await import('../src/document_start');
3636
};
3737

38-
describe('document_start service worker warm-up', () => {
38+
describe('document_start service worker messaging', () => {
3939
beforeEach(() => {
4040
mockSendMessage.mockClear();
4141
});
4242

43-
it('pings the service worker so it boots ahead of document_end', async () => {
43+
it('does not message the service worker, so nothing depends on it being awake', async () => {
4444
setLocation('');
4545

4646
await runDocumentStart();
4747

48-
expect(mockSendMessage).toHaveBeenCalledWith({ contentScriptQuery: 'warmup' });
49-
});
50-
51-
it('survives the ping going unanswered', async () => {
52-
setLocation('');
53-
54-
await expect(runDocumentStart()).resolves.not.toThrow();
48+
expect(mockSendMessage).not.toHaveBeenCalled();
5549
});
5650
});
5751

0 commit comments

Comments
 (0)