js-temporal/temporal-polyfill

`.toLocaleString` throws error in Chrome on macOS 14

twoBoots opened this issue · 10 comments

After updating to macOS 14 the polyfill throws an error in Chrome when calling toLocaleString on a PlainDateTime. The polyfill functions correctly in Firefox.

Reproduction here https://stackblitz.com/edit/temporal-polyfill-macos-chrome

macOS 14 Sonoma
Chrome 117
"@js-temporal/polyfill": "^0.4.4"

macOS 14 Chrome 117
image

macOS 14 Firefox
image

macOS 13 Chrome 117
image

Thanks for the report! Could you share the stack trace of the error?

Stacktrace for the above example:

ecmascript.ts:173 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getPossibleInstantsFor')
    at GetMethod (ecmascript.ts:173:18)
    at GetPossibleInstantsFor (ecmascript.ts:2833:65)
    at GetInstantFor (ecmascript.ts:2689:28)
    at extractOverrides (intl.ts:539:16)
    at DateTimeFormatImpl.format (intl.ts:193:32)
    at PlainDateTime.toLocaleString (plaindatetime.ts:384:49)

I'm also seeing another similar issue in Chrome 117 on macOS 14 calling Temporal.Now.plainDateISO(), happy to report this as a separate issue if preferred.

runtime-core.esm-bundler.js:221 Uncaught RangeError: Invalid time zone specified: undefined
    at new DateTimeFormat (<anonymous>)
    at getIntlDateTimeFormatEnUsForTimeZone (ecmascript.ts:356:16)
    at GetCanonicalTimeZoneIdentifier (ecmascript.ts:3148:21)
    at ParseTemporalTimeZone (ecmascript.ts:462:24)
    at ToTemporalTimeZoneSlotValue (ecmascript.ts:2592:10)
    at plainDateTimeISO (now.ts:19:14)
    at Temporal.Now.plainDateISO (now.ts:38:36)
    at PlainDate.now (PlainDate.ts:18:52)

Looking into the Invalid time zone specified error I have found that Temporal.Now.timeZoneId() is returning undefined

After working my way through the polyfill code, I've found the issue to be Chrome not setting timeZone

macOS 14 Chrome 117
image

Closing the issue here, will report to the Chrome team.

edit: added OS & Chrome version

Hi @twoBoots - I'm glad you've identified the root cause. Could you link the Chrome bug here after you've filed it?

Also, what does Firefox report in the same case?

Will link details here when I have them.

macOS 14 Firefox
image

macOS 13 Chrome 117

{
    "locale": "en-GB",
    "calendar": "gregory",
    "numberingSystem": "latn",
    "timeZone": "Australia/Melbourne",
    "year": "numeric",
    "month": "2-digit",
    "day": "2-digit"
}

I'm not sure I understand the results in your comment above. What changed between your earlier comment where Chrome reported undefined and when it reported Australia/Melbourne? Could it be that the OS needed some time after upgrading in order to find which time zone it was in?

In the last comment, Chrome on macOS 13 (previous) reported Australia/Melbourne, but Chrome on macOS 14 (latest) reports undefined.

This was probably unclear as the earlier comment didn't have the OS version beside the screenshot, I've updated it.