{"record":{"id":"e2ba3c3027f3ebb5","repo":"microsoft/playwright","slug":"invalid-timezone-id-timezoneid","errorCode":null,"errorMessage":"Invalid timezone ID: ${timezoneId}","messagePattern":"Invalid timezone ID: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/chromium/crPage.ts","lineNumber":1195,"sourceCode":"    await session.send('Emulation.setLocaleOverride', { locale });\n  } catch (exception) {\n    // All pages in the same renderer share locale. All such pages belong to the same\n    // context and if locale is overridden for one of them its value is the same as\n    // we are trying to set so it's not a problem.\n    if (exception.message.includes('Another locale override is already in effect'))\n      return;\n    throw exception;\n  }\n}\n\nasync function emulateTimezone(session: CRSession, timezoneId: string) {\n  try {\n    await session.send('Emulation.setTimezoneOverride', { timezoneId: timezoneId });\n  } catch (exception) {\n    if (exception.message.includes('Timezone override is already in effect'))\n      return;\n    if (exception.message.includes('Invalid timezone'))\n      throw new Error(`Invalid timezone ID: ${timezoneId}`);\n    throw exception;\n  }\n}\n\n// Chromium reference: https://source.chromium.org/chromium/chromium/src/+/main:components/embedder_support/user_agent_utils.cc;l=434;drc=70a6711e08e9f9e0d8e4c48e9ba5cab62eb010c2\nexport function calculateUserAgentMetadata(options: types.BrowserContextOptions) {\n  const ua = options.userAgent;\n  if (!ua)\n    return undefined;\n  const metadata: Protocol.Emulation.UserAgentMetadata = {\n    mobile: !!options.isMobile,\n    model: '',\n    architecture: 'x86',\n    platform: 'Windows',\n    platformVersion: '',\n  };\n  const androidMatch = ua.match(/Android (\\d+(\\.\\d+)?(\\.\\d+)?)/);\n  const iPhoneMatch = ua.match(/iPhone OS (\\d+(_\\d+)?)/);","sourceCodeStart":1177,"sourceCodeEnd":1213,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/chromium/crPage.ts#L1177-L1213","documentation":"Thrown by emulateTimezone (crPage.ts:1195) when Emulation.setTimezoneOverride fails with 'Invalid timezone' (and is not the benign 'already in effect' case). The timezoneId passed to newContext({ timezoneId }) is not accepted by Chromium — Playwright requires an IANA zone name.","triggerScenarios":"browser.newContext({ timezoneId: 'PST' }) or 'EST' / 'UTC+2' / a typo; passing a moment.js abbreviation; case-variant or locale names.","commonSituations":"Using timezone abbreviations instead of IANA IDs; copy-pasting zone names from non-IANA sources; testing on Chromium older than the zone database update.","solutions":["Use an IANA zone such as 'America/Los_Angeles', 'Europe/Berlin', or 'UTC'.","Validate before launch with Intl.supportedValuesOf('timeZone').includes(id).","Check the spelling and capitalization — IANA names are case-sensitive in some engines."],"exampleFix":"// before\nconst ctx = await browser.newContext({ timezoneId: 'PST' });\n// after\nconst ctx = await browser.newContext({ timezoneId: 'America/Los_Angeles' });","handlingStrategy":"validation","validationCode":"// Validate IANA zone before launch.\nconst id = 'America/Los_Angeles';\nconst valid = (Intl as any).supportedValuesOf\n  ? (Intl as any).supportedValuesOf('timeZone').includes(id)\n  : true; // fall back to a known-good list on older Node\nif (!valid) throw new Error(`Unknown IANA timezone: ${id}`);\nconst ctx = await browser.newContext({ timezoneId: id });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use IANA zone names (America/Los_Angeles, Europe/Berlin, UTC).","Never use abbreviations (PST, EST) or offset strings.","Validate with Intl.supportedValuesOf('timeZone') on Node 14+."],"tags":["timezone","context-options","emulation","chromium"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}