Skip to content

How to reduce cross-implementation incompatibility when new IDs are introduced? #6

@justingrant

Description

@justingrant

While reviewing bug reports on existing ECMAScript canonicalization behavior, I ran across a problematic case: when a new TZDB identifier is introduced, inevitably some environments will get it before others, and the slower-to-update environments will throw an exception when provided with that new ID. @Yqwed in #5 also raised this case.

When environments are evergreeen browsers, then the delay to get new IDs (and their accompanying Zone rules) is relatively short. But other environments could take months or years to update. For example:

  • Server apps, e.g. that may be running on a 2-year old Node version
  • Libraries that embed TZDB data, which may require a PR to update. typo in zone name Europe/Kyiv ? iamkun/dayjs#2059 is one example.
  • IoT devices, which may require a firmware update to change their TZDB
  • Android devices, which are dependent on the carrier to roll out updates
  • Enterprise environments where IT delays updates for a long time.
  • My family, all of whom seem to wait to update their devices until they stop working without applying updates. :-)
  • Or other slow-to-update cases

How can we help make this problem less bad?

When the new ID is present because of a name change like Kiev=>Kyiv, then there is something we could recommend in the spec: that implementations first introduce the identifier without making it canonical (so that it will be recognized if others send it, but because non-canonical it won't be sent to others), wait a bit (maybe a few months?), and then make the new name canonical?

This would have a weird side effect though, because currently (at least once we fix the 13 outdated canonical identifiers in V8 and WebKit) non-canonical identifiers never become canonical; instead, the transitions only go one way. Is it OK to break that regularly? And even if yes, is it good to delay canonicalizing new renames?

On the other hand, when it's a brand-new identifier representing a new Zone, I'm not sure there's much the spec can do, other than perhaps adding additional metadata to time zones, e.g. an addedDate property to Temporal.TimeZone which could allow applications to decide to hide newly-introduced identifiers from dropdown time zone choosers in UIs. This would add a maintenance burden because this added-date data is not available in TZDB. And it'd complicate the Temporal API. So I'm on the fence about whether the value of such an additional metadata is worth it.

I have also been thinking about adding a Temporal.TimeZone.p.metadata getter which initially could return an object, e.g. { version: '2022g' } and could be extended with additional metadata later like an added date if there's enough customer demand. See #7 for discussion.

Another thing we could do would be to encourage implementations to dynamically update to the latest TZDB more quickly (e.g. dynamically on install instead of being bundled into the distribution) but this would vary behavior for the same version of a browser, so I'm not sure that this would be good.

Regardless, one thing we should do is to encourage (e.g. in MDN docs) ECMAScript developers to anticipate this "unknown but not invalid identifier" case and to defend against it, using clearer error messages when an identifier is not recognized.

Feedback encouraged on this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions