Skip to content
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

Fix uncaught FirmwareNotRecognized in useAvailableLanguagesForDevice #5701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lemon-students-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/live-common": patch
---

Catch and return error in useAvailableLanguagesForDevice
6 changes: 6 additions & 0 deletions .changeset/twelve-nails-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
---

Add "FirmwareNotRecognized" to errors ignored by Sentry
2 changes: 2 additions & 0 deletions apps/ledger-live-desktop/src/sentry/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const ignoreErrors = [
"UnresponsiveDeviceError",
"PairingFailed",
"Ledger device: UNKNOWN_ERROR",
// wrong My Ledger provider selected for the firmware of the connected device
"FirmwareNotRecognized",
// errors coming from the usage of a Transport implementation
"HwTransportError",
// other
Expand Down
2 changes: 2 additions & 0 deletions apps/ledger-live-mobile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const excludedErrorName = [
"ManagerDeviceLocked",
"LockedDeviceError",
"UnresponsiveDeviceError",
// wrong My Ledger provider selected for the firmware of the connected device
"FirmwareNotRecognized",
// errors coming from the usage of a Transport implementation
"HwTransportError",
// other
Expand Down
27 changes: 21 additions & 6 deletions libs/ledger-live-common/src/manager/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,33 @@ export function useManagerBlueDot(dmi: DeviceModelInfo | null | undefined): bool

export const useAvailableLanguagesForDevice = (
deviceInfo?: DeviceInfo | null,
): { availableLanguages: Language[]; loaded: boolean } => {
): { availableLanguages: Language[]; loaded: boolean; error: Error | null } => {
const [availableLanguages, setAvailableLanguages] = useState<Language[]>([]);
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<Error | null>(null);

useEffect(() => {
let dead = false;
if (deviceInfo) {
manager
.getAvailableLanguagesDevice(deviceInfo)
.then(setAvailableLanguages)
.finally(() => setLoaded(true));
manager.getAvailableLanguagesDevice(deviceInfo).then(
languages => {
if (dead) return;
setAvailableLanguages(languages);
setError(null);
setLoaded(true);
},
error => {
if (dead) return;
setAvailableLanguages([]);
setError(error);
setLoaded(true);
},
);
}
return () => {
dead = true;
};
}, [deviceInfo]);

return { availableLanguages, loaded };
return { availableLanguages, loaded, error };
};