Safari issue: Failed to initialize NumberFormat since used feature is not supported in the linked ICU version

See original GitHub issue

Bug Description

There have been reports of the below dashboard error since 1.31.0 was released. This appears when accessing the primary Site Kit dashboard. Failed to initialize NumberFormat since used feature is not supported in the linked ICU version

One user has reported this only occurs in a Safari browser, troubleshooting ongoing with the other.

Full error details below for 1 user
Failed to initialize NumberFormat since used feature is not supported in the linked ICU version

    in DataBlock
    in div
    in div
    in section
    in LegacySearchConsoleDashboardWidgetOverview
    in withData(LegacySearchConsoleDashboardWidgetOverview)
    in Unknown
    in WithSelect(withData(LegacySearchConsoleDashboardWidgetOverview))
    in div
    in Layout
    in div
    in div
    in div
    in div
    in GoogleSitekitSearchConsoleDashboardWidget
    in FilteredComponent
    in WithFilters(ModuleApp)
    in ModuleApp
    in GoogleSitekitModule
    in RestoreSnapshots
    in ErrorHandler
    in Root
Full error for second user (slightly different - **_LegacySearchConsoleDashboardWidgetTopLevel_**)
Failed to initialize NumberFormat since used feature is not supported in the linked ICU version
in DataBlock
in div
in LegacySearchConsoleDashboardWidgetTopLevel
in withData(LegacySearchConsoleDashboardWidgetTopLevel)
in Unknown
in WithSelect(withData(LegacySearchConsoleDashboardWidgetTopLevel))
in FilteredComponent
in FilteredComponent
in WithFilters(LegacyDashboardSearchFunnelInner)
in div
in div
in div
in Layout
in div
in LegacyDashboardSearchFunnel
in FilteredComponent
in FilteredComponent
in FilteredComponent
in WithFilters(LegacyDashboardModule)
in div
in Row
in div
in Grid
in div
in DashboardApp
in GoogleSitekitDashboard
in RestoreSnapshots
in ErrorHandler
in Root

Impacted users:

Additional Context

  • Occurred since 1.31.0
  • Unable to recreate in support site (Safari 14 on Mac - Big Sur). Tested via Browserstack
  • Site Health information provided by both users
  • No matching plugins
  • One user reported the issue no longer occurs after using the Health Check & Troubleshooting plugin and then exiting troubleshooting mode.

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • NumberFormat should not fail to initialize due to unsupported features in supported browsers, specifically Safari 14.1 on MacOS Mojave
  • Other similar classes used under Intl.* should also be checked for similar compatibility errors

Implementation Brief

  • In /assets/js/util/i18n.js export const numberFormat()
  • Wrap Intl.NumberFormat in a try/catch, if an error is thrown we call our new logging function (defined further in the IB) with a message: Unable to: new Intl.NumberFormat( ${ JSON.stringify( locale ) }, ${ JSON.stringify( formatOptions ) } ).format( ${ number } );
  • Remove the following formatOption key/values if they exist:
{
	currencyDisplay: 'narrow',
	currencySign: 'accounting',
	style: 'unit',
}

Remove these formatOption keys irrespective of value: [ 'signDisplay', 'compactDisplay' ]

Test Coverage

  • Jest tests can be updated to not expect a console.warn(), however we can’t run our tooling in a specific version of a specific browser to ensure it isn’t broken.

Visual Regression Changes

  • N/A

QA Brief

  • Confirm you’re on an affected browser/OS by running either of these two in your console:
  • new Intl.NumberFormat('en-US', {style: "percent", signDisplay: "never", maximumFractionDigits: 1}).format(1.234)
  • new Intl.NumberFormat( "en-US", {"unitDisplay":"narrow","style":"unit","unit":"second"} ).format( 1 );
  • With an affected browser open your console and browse to the main dashboard with analytics connected /wp-admin/admin.php?page=googlesitekit-dashboard
  • Confirm you have the at least one warning in your console related to Intl.NumberFormat, similar to the followingUnable to: new Intl.NumberFormat( "en-US", {"style":"percent","signDisplay":"never","maximumFractionDigits":1} ).format( 0.09 );

Changelog entry

  • Fix a bug related to localized number formatting for browsers that have limited support for formatting options.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:50 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ivankruchkoffcommented, Jun 22, 2021

14.0 does not repro the bug, updated safari to 14.1.1 and can see the same issue.

Screen Shot 2021-06-22 at 5 24 03 PM
2reactions
dlockhartcommented, Jun 17, 2021

It looks like Apple has fixed this in their nightlies as of ~June 10, although I can’t confirm it since I also can’t reproduce this either. Whatever having an “old ICU” means must be the thing that does it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to initialize NumberFormat - WordPress.org
... “Failed to initialize NumberFormat” error: Failed to initialize NumberFormat since used feature is not supported in the linked ICU version in DataBlock ......
Read more >
Maybe because they commented out the code on their site ...
on: A problem repeatedly occurred with Safari 14.1 ... Failed to initialize NumberFormat since used feature is not supported in the linked ICU...
Read more >
JavaScript built-in: Intl: NumberFormat: format - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Intl.NumberFormat.prototype.formatToParts support for Safari ...
The components render React elements by building on React Intl's imperative API. this might help us on the device when Intl.NumberFormat.
Read more >
How to quickly fix common recording errors - Loom support
This is a great place to start your troubleshooting. 🔧 There are a few things that tend to fix most common problems. Here's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found