Skip to content

Retry on failed ICU data load, ignoring NODE_ICU_DATA or --icu-data-dir #32466

Open
@srl295

Description

@srl295

Related to #30825 (I had the idea during its discussion) and, from the icebox, #3460

Is your feature request related to a problem? Please describe.
Currently, Node with an invalid/missing ICU data directory ( set with NODE_ICU_DATA or --icu-data-dir ) just fails.

$ nvm i --lts
Installing latest LTS version.
v12.16.1 is already installed.
$ node --icu-data-dir=/tmp
node: could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir parameters)

Describe the solution you'd like

It might be possible to fall back as if the --icu-data-dir was not specified (or the default data dir in #30825 was not present.)

As early as that error message is generated, it might be possible to call u_cleanup() to unload ICU and then reinitialize it using the baked-in data or other defaults.

This could be done completely within InitializeICUDirectory(), although it might be advantageous to allow programmatic detection of the fact that this fallback happened. Ideas there:

  1. expose const char *u_getDataDirectory() via the ICU process binding.
  2. provide the eventual path string via some kind of variable
  3. print out a warning (not a good idea)
  4. some other flag
  5. do nothing - this would probably be OK if there isn't a strong use case (other than perhaps test cases)

FYI @sam-github @sgallagher @nodejs/i18n-api

Describe alternatives you've considered
There's really no alternative to restarting the node process at this point.

Metadata

Metadata

Assignees

Labels

cliIssues and PRs related to the Node.js command line interface.i18n-apiIssues and PRs related to the i18n implementation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions