-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry on failed ICU data load, ignoring NODE_ICU_DATA or --icu-data-dir #32466
Comments
So, just to clarify, the issue here is when Node has been called with a specific It seems to me that this would then be a case of "operator error" and that reporting the error back to the user makes sense. Maybe it's appropriate just to make the error message more detailed, such as:
|
It could be several things: (and note that the "dir" is really a search path):
(This is probably a good change to make in the wording anyway.) It could be classified as operator error. V8 certainly thinks so, and used to fail with fatal errors for related problems. But it could also be the situation where the user has upgraded their Node version, or deployed the same directory to a different hardware architecture, etc. Now, Node.js as packaged by default, has a built in full data file. However, that data file is not on the "search path" if the user specifies one. Put another way: You can't deploy Node.js unconditionally calling it with This PR provides an in-between. There could be additional controls, such as a build option to "not bake in data", or a runtime/build option to "fail if --icu-data-dir does not contain data", but I think for many users, this fallback might be an improvement. A data point: 7,000 hits on SO for node: could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir parameters — perhaps many of the users would be benefitted by "fail fast", but some might benefit from some kind of a warning. Perhaps |
My concern here is violating the Principle of Least Surprise. If I specify Maybe it would be better for Node.js upstream to behave the way the Fedora packaging does. Instead of building |
👍 and I definitely hear that. That's why this isn't a PR.
That was somewhat of the idea in #3460, the problem is that Node.js is shipped as a tarball, so a well-known location can be harder to come by. Let me see if I can distill some thoughts and specific action items here : A. First, I think the default of building full-icu for upstream is generally simpler. You can still override the data, but by default it just works. I can see the model you mentioned where Node.js has an 'installer' (dnf, Mac, nvm, brew), but it seems we are getting fewer issues after this change. B. Perhaps we can reduce user surprise by making some things explicit:
|
My current thinking is that I'd prefer that if we can't do what you ask it results in an error like it does now. In terms of being able to additionally specify to fall back I wonder if it is a common enough use case to warrant the extra work/code? |
Consider the scenario:
In any event, I think I am fine with closing this if it's going to cause more confusion than not. The error message clearly needs work… Perhaps the error message could suggest removing the path if it is not needed (especially if baked in full data is detected)? |
I haven't played with icu, so let me see if I understand:
Do this, and the app fails, because full-icu installed with node10 isn't compatible with node12? If that's the situation, it seems the same as node addons. Would the same solution, rebuilding, not work? You can't generally take an installed node_modules folder and keep it between node majors. Or am I missing something more unique to icu that makes this worse than usual for users? |
@srl295 I like the idea of the error message for the case where the requested data cannot be found indicating that you may not need the command line option anymore for versions where the data is bundle in. |
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.
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:const char *u_getDataDirectory()
via the ICU process binding.print out a warning(not a good idea)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.
The text was updated successfully, but these errors were encountered: