-
Notifications
You must be signed in to change notification settings - Fork 28
Fix bug where bundleMapQueue is not cleared after an error #70
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
Conversation
|
Thank you for reporting the issue and for providing a solution in this PR. I have left one comment above. Thanks |
|
Hi @rxaviers , I've also added some more comments to the test so it is easier to understand in the future for new people and once we forget about this :) (Also added a signed-off-by to the commits) |
Signed-off-by: Georgi Tsaklev <[email protected]>
Signed-off-by: Georgi Tsaklev <[email protected]>
…shift instead of .forEach Signed-off-by: Georgi Tsaklev <[email protected]>
|
Awesome! Looks great. Thanks a lot |
| minBundle = minBundle.join(Cldr.localeSep); | ||
| existing = availableBundleMap[minBundle]; | ||
| if (existing && existing.length < bundle.length) { | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late review... This should also be break.
|
Ah, Completely missed that return :) yeah, I think it still achieves what we aimed for, thanks for validating it with your internal libs 🥇 |
Fixes #69
What happened
At the Localisation & Globalisation team at my company, we've decided to release an internal "test" locale (we called it xx-XX) to provide pseudo localisation for all other teams across. Since this locale is fictional there is no CLDR data for it. Our approach was to take es-ES and alter the data so that it acts as the new xx-XX locale.
During the process we've missed the likelySubtags object, meaning there was a mismatch
The error
Passing this data into a
Globalize.load()(which in turn callsCLDR.load()) causes no errors, however, instantiating a new instancenew Globalize(locale)throwsTypeError: Cannot read property '0' of undefined. Note that whatlocaleis above doesn't matter. Locales with already loaded valid data can no longer be used.Expected outcome
An error to be thrown only once and the data is ejected from the queue to allow the application to continue without a need to restart.
Impact
The service that observed the error is using Globalize in its backend. This means that after an internal user (xx-XX is only an internal locale, no end-user can request it) tested the new locale end-users using actual locales started seeing errors due to the recurring exception thrown for valid locales.
Why this fixed it
I have moved the clearing of the _availableBundleMapQueue to before the iteration over it. That way even if there is an error in the code below the error will happen only once. There appear to be no other exit points before the queue clearing, so pulling it earlier is not changing the behaviour.