-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Save Brave Fixes #4270 #4524
Save Brave Fixes #4270 #4524
Conversation
|
||
// safeguard for Brave Browser until they implement chrome.i18n.getAcceptLanguages | ||
// https://github.com/MetaMask/metamask-extension/issues/4270 | ||
if(!userPreferredLocaleCodes){ |
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.
Can I catch it? Not really; it's not raised by your code, but the cleanup code that handles async tasks in Chrome API; therefore using try ... catch in your callback won't help. Since it's asynchronous, using try around the original API call won't help either.
shoutouts to: https://stackoverflow.com/questions/28431505/unchecked-runtime-lasterror-when-using-chrome-api
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.
I think this leaves out part of the fix that Brave recommended, could you verify? Had this fixed the problem after you'd reproduced it?
@@ -2,8 +2,7 @@ const extension = require('extensionizer') | |||
const promisify = require('pify') | |||
const allLocales = require('../../_locales/index.json') | |||
|
|||
const isSupported = extension.i18n && extension.i18n.getAcceptLanguages | |||
const getPreferredLocales = isSupported ? promisify( | |||
const getPreferredLocales = extension.i18n ? promisify( |
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.
My understanding is that Brave does expose a extension.i18n
object, and even a getAcceptLanguages
method on it, so they would pass this test.
From what they reported and I relayed in this comment, the only way to check their failure right now is to check chrome.runtime.lastError
within the callback, and if there's an error, then fall back.
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.
Yes, both evaluate successfully for Brave. Do you think it makes sense to keep the extension.i18n check for protection in browsers that don't expose i18n at all?
(am not sure how prevalent this is/would be)
Checking for the runtime.lastError did not seem to resolve, but possibly due to how it was wrapped in pify - I'll take another look.
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.
Per feedback from Brave, we are now handling errors from this function, because Brave currently throws for this.
Without evaluating the runtime.lastError, Brave returns undefined so the proposed change does fix the issue. |
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.
Sounds like this works, and it shouldn't break any normally compatible browsers, so this is safe to merge.
@jennypollack Would you mind adding a user-facing entry to the |
CHANGELOG.md
Outdated
@@ -3,6 +3,7 @@ | |||
## Current Master | |||
|
|||
- Fix bug where account reset did not work with custom RPC providers. | |||
- Fix for Brave i18n getAcceptLanguages [#4270](https://github.com/MetaMask/metamask-extension/issues/4270) |
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.
@jennypollack we add changelog entries under "current master" and then move that to a version number of release
From Brave Sampson:
|
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.
Left a comment from Brave, I'd like us to adjust to their specifications.
In Brave Browser extension.i18n.getAcceptLanguages throws:
"Unchecked runtime.lastError while running i18n.getAcceptLanguages: Access to extension API denied."
Once Brave Browser implementation lands for locale support, no further change will be needed in MM to support language preferences.
Meanwhile this check should allow MetaMask to load on Brave.