{"record":{"id":"c0568f2334b5c777","repo":"grafana/k6","slug":"emulating-timezone-q-w","errorCode":null,"errorMessage":"emulating timezone %q: %w","messagePattern":"emulating timezone %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":213,"sourceCode":"\nfunc (fs *FrameSession) emulateLocale() error {\n\taction := emulation.SetLocaleOverride().WithLocale(fs.page.browserCtx.opts.Locale)\n\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\tif strings.Contains(err.Error(), \"Another locale override is already in effect\") {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"emulating locale %q: %w\", fs.page.browserCtx.opts.Locale, err)\n\t}\n\treturn nil\n}\n\nfunc (fs *FrameSession) emulateTimezone() error {\n\taction := emulation.SetTimezoneOverride(fs.page.browserCtx.opts.TimezoneID)\n\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\tif strings.Contains(err.Error(), \"Timezone override is already in effect\") {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"emulating timezone %q: %w\", fs.page.browserCtx.opts.TimezoneID, err)\n\t}\n\treturn nil\n}\n\nfunc (fs *FrameSession) getNetworkManager() *NetworkManager {\n\treturn fs.networkManager\n}\n\nfunc (fs *FrameSession) initDomains() error {\n\tactions := []Action{\n\t\t// TODO: can we get rid of the following by doing DOM related stuff in JS instead?\n\t\tdom.Enable(),\n\t\tcdplog.Enable(),\n\t\tcdpruntime.Enable(),\n\t\ttarget.SetAutoAttach(true, true).WithFlatten(true),\n\t}\n\tfor _, action := range actions {\n\t\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame_session.go#L195-L231","documentation":"FrameSession.emulateTimezone (frame_session.go:213) sends Emulation.setTimezoneOverride with the `timezoneId` browser-context option. Chromium validates the ID against its IANA tz database and rejects unknown names (except the swallowed 'already in effect' case), wrapping the error with the offending timezone. Like locale failures, this aborts page initialization.","triggerScenarios":"browser.newContext({ timezoneId: 'America/Nowhere' }), typos like 'UTC+2' or 'GMT-5' (not IANA IDs), 'Asia/Calcutta'-style outdated names on some builds, or an empty string passed explicitly instead of omitted.","commonSituations":"Using offsets or Windows timezone names instead of IANA IDs, timezone data missing from minimal container images (tzdata not installed / slim chromium build), or config-driven timezone strings that are never validated.","solutions":["Use a valid IANA timezone ID, e.g. 'America/New_York', 'Europe/Berlin', 'UTC'","Validate the ID in Node before the run: Intl.DateTimeFormat(undefined, { timeZone: id }) throws for unknown IDs","Ensure tzdata is installed in the container running chromium"],"exampleFix":"// before\nconst ctx = browser.newContext({ timezoneId: 'GMT+2' });\n\n// after\nconst ctx = browser.newContext({ timezoneId: 'Europe/Berlin' });","handlingStrategy":"validation","validationCode":"function validTimezone(tz) {\n  if (!tz) return tz;\n  try {\n    new Intl.DateTimeFormat(undefined, { timeZone: tz }); // throws for unknown IANA IDs\n    return tz;\n  } catch {\n    throw new Error(`timezoneId is not a valid IANA ID: ${tz}`);\n  }\n}\nbrowser.newContext({ timezoneId: validTimezone(cfg.timezoneId) });","typeGuard":"function isIanaTimezone(v: unknown): v is string {\n  if (typeof v !== 'string') return false;\n  try { new Intl.DateTimeFormat(undefined, { timeZone: v }); return true; } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Use IANA IDs ('Europe/Berlin'), never offsets ('GMT+2') or Windows names","Install tzdata in slim containers running chromium"],"tags":["browser","timezone","emulation","context-options","i18n"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}