-
-
Notifications
You must be signed in to change notification settings - Fork 276
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(connect): FW revision check offline handling #15664
Conversation
@@ -87,7 +95,7 @@ export const checkFirmwareRevision = async ({ | |||
|
|||
return { success: true }; | |||
} catch (e) { | |||
if (e.name === 'FetchError' && e.code === 'ENOTFOUND') { |
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.
This catches only when network adapter is on, but there is no response or 4xx or 5xx response from server.
This did not catch error when network adapter is off. And that's is not an edge case - laptop/mobile users can routinely toggle Wi-Fi to save battery power...
Handling it in getOnlineReleaseMetadata
makes sure we catch any fetch error, while still distinguishing from other-error
in main function body.
isEqual(onlineRelease.version, firmwareVersion), | ||
); | ||
} catch { | ||
throw OFFLINE_ERROR; |
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.
This will hide original error.
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.
Also I do not really like throwing something what is not the exception (in JS the Error
)
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.
The original implementation did not use the error either 🤷
It only reported failFirmwareRevisionCheck('other-error')
or failFirmwareRevisionCheck('cannot-perform-check-offline')
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.
Great innitiative, but unfortunately, it reintroduces the bug I attempted to fix in #14626.
I reproduced it by using a T3B1 device, removing 2.8.3 from releases.json, and changing the URL to
https://raw.githubusercontent.com/trezor/data/d704edf1dfff1fe97226af706ac8eff6291c6bb8/firmware/t3b1/releases.json` - this leads to a JSON which cannot be parsed.
Right. Meanwhile I also noticed when looking into the failing unit test, that the current behavior was done intentionally. |
Description
Fix handling of fetch errors when FW revision check encounters version not known locally.
You can test locally with user env
1-main | 2-main
and turning off Wi-Fi.Or you can start a released emulator and delete the corresponding entry from
releases.json
, and try it with Wi-Fi on/off.Screenshots:
Before:
![other error](https://private-user-images.githubusercontent.com/5287903/391498932-8e3ec38c-6e79-43fa-8373-0c473a9bd445.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTY0NjcsIm5iZiI6MTczOTU5NjE2NywicGF0aCI6Ii81Mjg3OTAzLzM5MTQ5ODkzMi04ZTNlYzM4Yy02ZTc5LTQzZmEtODM3My0wYzQ3M2E5YmQ0NDUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTVUMDUwOTI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTc4YzE3MWUxYzJiMDM3OWFjMzk3NGE0NTIzMWFjYjNmYzc0Zjc1MThmZGQ0NTY3NmQ0NmZiYTViOTNlMjRkOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.0DzdzJsi--fcCTTsDheMD84zD1V1JgxQyNzOKEyzG1Y)
After:
![offline error](https://private-user-images.githubusercontent.com/5287903/391498925-ec134a28-a282-4057-9a88-dda218bb8881.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTY0NjcsIm5iZiI6MTczOTU5NjE2NywicGF0aCI6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