{"record":{"id":"c0fbaf13b7c2137a","repo":"microsoft/playwright","slug":"invalid-timezone-id-contextoptions-timezoneid","errorCode":null,"errorMessage":"Invalid timezone ID: ${contextOptions.timezoneId}","messagePattern":"Invalid timezone ID: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/webkit/wkPage.ts","lineNumber":217,"sourceCode":"    if (bootstrapScript.length)\n      promises.push(session.send('Page.setBootstrapScript', { source: bootstrapScript }));\n    this._page.frames().map(frame => frame.evaluateExpression(nullProgress, bootstrapScript).catch(e => {}));\n    if (contextOptions.bypassCSP)\n      promises.push(session.send('Page.setBypassCSP', { enabled: true }));\n    const emulatedSize = this._page.emulatedSize();\n    if (emulatedSize) {\n      promises.push(session.send('Page.setScreenSizeOverride', {\n        width: emulatedSize.screen.width,\n        height: emulatedSize.screen.height,\n      }));\n    }\n    promises.push(session.send('Network.setExtraHTTPHeaders', { headers: headersArrayToObject(this._calculateExtraHTTPHeaders(), false /* lowerCase */) }));\n    if (contextOptions.offline)\n      promises.push(session.send('Network.setEmulateOfflineState', { offline: true }));\n    promises.push(session.send('Page.setTouchEmulationEnabled', { enabled: !!contextOptions.hasTouch }));\n    if (contextOptions.timezoneId) {\n      promises.push(session.send('Page.setTimeZone', { timeZone: contextOptions.timezoneId }).\n          catch(e => { throw new Error(`Invalid timezone ID: ${contextOptions.timezoneId}`); }));\n    }\n    if (this._page.fileChooserIntercepted())\n      promises.push(session.send('Page.setInterceptFileChooserDialog', { enabled: true }));\n    promises.push(session.send('Page.overrideSetting', { setting: 'FullScreenEnabled', value: !contextOptions.isMobile }));\n    promises.push(session.send('Page.overrideSetting', { setting: 'NotificationsEnabled', value: !contextOptions.isMobile }));\n    promises.push(session.send('Page.overrideSetting', { setting: 'PointerLockEnabled', value: !contextOptions.isMobile }));\n    promises.push(session.send('Page.overrideSetting', { setting: 'InputTypeMonthEnabled', value: contextOptions.isMobile }));\n    promises.push(session.send('Page.overrideSetting', { setting: 'InputTypeWeekEnabled', value: contextOptions.isMobile }));\n    promises.push(session.send('Page.overrideSetting', { setting: 'FixedBackgroundsPaintRelativeToDocument', value: contextOptions.isMobile }));\n    promises.push(session.send('Page.overrideSetting', { setting: 'PushAPIEnabled', value: !contextOptions.isMobile }));\n    await Promise.all(promises);\n  }\n\n  private _initializeFrameSessions(frame: Protocol.Page.FrameResourceTree, promises: Promise<any>[]) {\n    const session = this._targetIdToFrameSession.get(`frame-${frame.frame.id}`);\n    if (session)\n      promises.push(session.initialize());\n    for (const childFrame of frame.childFrames || [])","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/webkit/wkPage.ts#L199-L235","documentation":"When a contextOptions.timezoneId is set, WebKit issues Page.setTimeZone; if the engine rejects the timezone string (unrecognized IANA zone), the .catch rewraps it as 'Invalid timezone ID: <id>'. WebKit only accepts valid IANA timezone identifiers.","triggerScenarios":"Launching a context with newContext({ timezoneId: '...' }) where the value is misspelled, non-IANA, or not present in the OS tz database. Also contextOptions updates that re-apply an invalid zone.","commonSituations":"Typos like 'UTC+2' or 'EST' (use 'America/New_York'), 'GMT' variants, or zones absent on minimal CI images. Copying timezone strings from non-IANA sources.","solutions":["Use a canonical IANA timezone id, e.g. 'America/New_York', 'Europe/Berlin', 'UTC'.","On Linux CI ensure the tzdata package is installed so the zone database is complete.","Validate the id against Intl.supportedValuesOf('timeZone') (modern Node) before passing it."],"exampleFix":"// before\nconst ctx = await browser.newContext({ timezoneId: 'EST' });\n\n// after\nconst ctx = await browser.newContext({ timezoneId: 'America/New_York' });","handlingStrategy":"validation","validationCode":"const known = new Set(typeof Intl !== 'undefined' && Intl.supportedValuesOf ? Intl.supportedValuesOf('timeZone') : ['UTC']);\nfunction validTz(tz) { return !tz || known.has(tz); }","typeGuard":"function isIanaTimezone(tz: string): boolean {\n  if (typeof Intl !== 'undefined' && Intl.supportedValuesOf) return Intl.supportedValuesOf('timeZone').includes(tz);\n  return tz === 'UTC' || tz.includes('/');\n}","tryCatchPattern":"try { await browser.newContext({ timezoneId }); }\ncatch (e) {\n  if (/Invalid timezone ID/.test(e.message)) await browser.newContext({ timezoneId: 'UTC' });\n  else throw e;\n}","preventionTips":["Use canonical IANA ids (America/New_York, Europe/Berlin, UTC).","Install tzdata on minimal Linux CI images."],"tags":["webkit","timezone","emulation","context-options"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}