-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Intermittent RangeError: Incorrect locale information provided
in i18next.getLocale(request)
#209
Comments
I think it relates to my issue #207 because apart from my error, it shows me the same error as yours |
sergiodxa
pushed a commit
that referenced
this issue
Sep 17, 2024
…cale (#211) Hi, following up on my #207 and someones #209. This PR consists of two changes. ## Filter out invalid locales instead of throwing exceptions I have MANY thrown exception in Sentry from my users. Sometimes it's just bots, sometimes it's a weird combination of environment and browsers. However sometimes a request i received contains an invalid locale (see tests, there are real world `Accept-Language` headers). In my opinion it's better to gracefully filter out one of the invalid locales instead of throwing an exception (`Intl.DateTimeFormat.supportedLocalesOf` does that) ## Better handling of whitespaces Even though you have tests for random whitespaces, it doesn't handle all the cases as i have observed. The [specification](https://datatracker.ietf.org/doc/html/rfc3282#section-3) specifies multiple places where whitespaces can occur, i have handled the additional whitespaces and also made a test from one of my Sentry errors that bypassed your test.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
From time to time, I'm getting the following error at this line:
let lng = await i18next.getLocale(request)
I have no idea how to debug this, let me know if you want me to set something up to debug the issue.
Here's a screenshot from Sentry:
Your Example Website or App
https://gista.co/
Steps to Reproduce the Bug or Issue
Set up as README along with
i18n.ts
configured as follows:Expected behavior
No error
Screenshots or Videos
No response
Platform
From Sentry:
Additional context
No response
The text was updated successfully, but these errors were encountered: