Repository navigation
Description
Version
1.65.0 (latest release tested)
Steps to reproduce
Minimal reproduction, using only Playwright and a minimal Manifest V3 extension.
git clone --branch service-worker-timezone --single-branch https://github.com/vitalets/playwright-issues.git
cd playwright-issues
npm ci
npx playwright install chromium
# Adjust timezoneId in test/timezone.spec.ts if needed.
npm testChoose a timezoneId different from your system timezone. The example uses Europe/Madrid; if your system already uses Madrid, change the timezoneId variable in test/timezone.spec.ts to Asia/Tokyo (no other changes are needed). Matching timezones mask the bug.
The test verifies the configured timezone in an ordinary page, then loads an extension whose first statement records its worker's timezone and parses 2030-01-01T23:00. No extension page is opened, and no timezone environment variable is set.
Expected behavior
The service worker uses the configured timezoneId from its first statement. Its timezone and parsed date match the page's values.
Actual behavior
The page uses the configured timezone, but the worker retains the system timezone. On my Madrid-configured machine, changing the example to Asia/Tokyo produces:
- "timezone": "Asia/Tokyo"
+ "timezone": "Europe/Madrid"
- "localDate": "2030-01-01T14:00:00.000Z"
+ "localDate": "2030-01-01T22:00:00.000Z"Additional context
Reproduced with bundled Chromium 158.0.8127.18 on macOS. No clock mocking or third-party helpers are involved.
Both web extensions and regular websites are affected:
- Web extension: the linked reproduction loads an extension without opening an extension page. Its worker starts with the system timezone instead of the configured timezone.
- Regular website: in a separate local experiment, I registered a service worker, closed the persistent browser context, reopened the same profile with the same timezone setting, and started the registered worker using CDP
ServiceWorker.startWorker, without reopening the site. Its first statement also recorded the browser default timezone instead of the configured timezone.
The most confusing behavior is that opening an extension page in a tab implicitly changes the service worker’s timezone to the configured timezoneId. The page and worker share the same Chromium renderer process, so the page’s timezone affects worker.
Page initialization applies the context's timezoneId, while service-worker initialization resumes execution without applying it.
Environment
Relevant output from npx envinfo --preset playwright:
System:
OS: macOS 26.6.2
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 24.16.0
npm: 11.21.1
npmPackages:
@playwright/test: 1.65.0 => 1.65.0
Activity
vitalets commentedon Nov 8, 2026
I'm ready to submit a PR applying
timezoneIdto service workers, following the same approach used for pages.Conceptually:
packages/playwright-core/src/server/chromium/crServiceWorker.ts
import { CRNetworkManager } from './crNetworkManager'; +import { emulateTimezone } from './crPage'; session.send('Runtime.enable', {}).catch(e => { }); + if (browserContext._options.timezoneId) + emulateTimezone(session, browserContext._options.timezoneId).catch(e => { }); session.send('Runtime.runIfWaitingForDebugger').catch(e => { });github-actions commentedon Nov 9, 2026
microsoft-playwright-automation commentedon Nov 9, 2026
Hi, I'm the Playwright bot and I reproduced this on Linux.
Reproduced on main
51328259d100b64f5e51ec025668dfe22532ac3b(1.66.0-next), Chromium 158.0.8127.18. The extension worker records UTC instead of Asia/Tokyo at its first statement. Service-worker initialization does not apply the context's timezone before resuming execution. Applying the existing page timezone helper there fixes both the timezone and local-date parsing.Reproduction and checks
I extended
CR-037 should give access to the service workerintests/library/chromium/extensions.spec.ts, using the existing minimal MV3 extension. Its worker records this before any other code:The test launches the extension with
timezoneId: 'Asia/Tokyo'and reads the saved value without opening an extension page. Before the fix it returns{ timezone: 'UTC', localDate: '2030-01-01T23:00:00.000Z' }; with the fix it returns{ timezone: 'Asia/Tokyo', localDate: '2030-01-01T14:00:00.000Z' }.All checks used the checkout above plus the proposed patch:
npm run buildandnpm run flintpassed.An initial Firefox run had one test-server port conflict with the concurrent headed Chromium run. Running the files sequentially passed. I did not run macOS or the published 1.65.0 package; the bug reproduces on main.
Draft PR: #44021
Triaged on Linux by the Playwright bot - agent run
chore: mark v0.1.25 (#546)