cube-js/cube · warning

Failed to generate d3 local via Intl, failing back to en-US

Error message

Failed to generate d3 local via Intl, failing back to en-US

What it means

d3 number formatting needs a locale definition. Cube first checks a bundled map of known locales; for others it derives one from Intl. If Intl-based derivation throws, the client logs this warning and falls back to the bundled en-US definition.

Source

Thrown at packages/cubejs-client-core/src/format-d3-numeric-locale.ts:97

}

const localeCache: Record<string, FormatLocaleObject> = Object.create(null);

export function getD3NumericLocale(locale: string, currencyCode = 'USD'): FormatLocaleObject {
  const key = `${locale}:${currencyCode}`;
  if (localeCache[key]) {
    return localeCache[key];
  }

  let definition: FormatLocaleDefinition;

  if (formatD3NumericLocale[locale]) {
    definition = { ...formatD3NumericLocale[locale], currency: getCurrencyOverride(locale, currencyCode) };
  } else {
    try {
      definition = getD3NumericLocaleFromIntl(locale, currencyCode);
    } catch (e: unknown) {
      console.warn('Failed to generate d3 local via Intl, failing back to en-US', e);

      definition = {
        ...formatD3NumericLocale['en-US'],
        currency: getCurrencyOverride(locale, currencyCode)
      };
    }
  }

  localeCache[key] = formatLocale(definition);
  return localeCache[key];
}

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Use a locale supported by the runtime's Intl implementation
  2. Pass one of the bundled locales in formatD3NumericLocale (e.g. en-US, de-DE)
  3. Ensure Node has full ICU (full-icu / recent Node build) if server-side
  4. If intentional, ignore the warning — formatting falls back to en-US

Example fix

// before
"format": { currency: ['EUR'] }, locale: 'xx-XX'
// after
"format": { currency: ['EUR'] }, locale: 'de-DE'
Defensive patterns

Strategy: fallback

Validate before calling

function localeSupported(l: string): boolean {
  try { new Intl.NumberFormat(l); return true; } catch { return false; }
}

Type guard

function isValidLocale(l: string): boolean {
  try { new Intl.NumberFormat(l).resolvedOptions(); return true; } catch { return false; }
}

Try / catch

try {
  new Intl.NumberFormat(locale, { style: 'currency', currency });
} catch (e) {
  console.warn('Locale unsupported, using en-US');
  locale = 'en-US';
}

Prevention

When it happens

Trigger: getD3NumericLocale is called with a locale not present in formatD3NumericLocale and getD3NumericLocaleFromIntl(locale, currencyCode) throws (e.g. unsupported/invalid locale tag passed to Intl.NumberFormat).

Common situations: Browsers/runtimes without full ICU coverage for a locale; a non-standard locale string passed in the Cube query format config; running in Node builds compiled without full-icu.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/d5e595ab833d9c6c. Report an issue: GitHub.