Skip to content

Fix telemetry throwing when the default locale is invalid - #157

Open
AlexPayment wants to merge 1 commit into
stytchauth:mainfrom
AlexPayment:fix/telemetry-timezone-invalid-locale
Open

AlexPayment wants to merge 1 commit into
stytchauth:mainfrom
AlexPayment:fix/telemetry-timezone-invalid-locale

Conversation

@AlexPayment

Copy link
Copy Markdown

Description

NetworkClient.createTelemetryBlob() reads the time zone with Intl.DateTimeFormat().resolvedOptions().timeZone. Browsers with an invalid default locale throw RangeError: Internal error. Icu error. on that call. We saw it on browsers with navigator.language set to united states-UNITED STATES.

createTelemetryBlob() runs in the StytchClient constructor (the sdk_instance_instantiated event). In the Next.js setup, where the client is created at module scope, the whole page crashes.

This PR wraps the lookup in a getTimezone() helper. If the call without a locale throws, it retries with 'en-US'. The time zone doesn't depend on the locale, so the reported value doesn't change. If that fails too, it returns an empty string, so telemetry can never break the SDK.

Includes a patch changeset for @stytch/nextjs, @stytch/react and @stytch/vanilla-js.

Test plan

  • Added NetworkClient.spec.ts tests: falls back to a fixed locale when the default one throws, and returns an empty time zone when every locale throws. Both fail without the fix.
  • yarn workspace @stytch/web test: 492 tests pass
  • yarn workspace @stytch/web typecheck
  • yarn lint

@changeset-bot

changeset-bot Bot commented Oct 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cf98d22

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@stytch/nextjs Patch
@stytch/react Patch
@stytch/vanilla-js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 31, 2026

Copy link
Copy Markdown

@AlexPayment is attempting to deploy a commit to the Stytch Auth Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant