This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
LL-9033 Handle inner exception after pairing timeout #778
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🦒 Context (issues, jira)
https://ledgerhq.atlassian.net/browse/LL-9033
💻 Description
This is a bit of a pickle, for context the new
fw 2.0.2
introduced some changes to the new characteristic, the one that brought the performance boost13d63400-2c97-0004-0003-4c6564676572
, which threw an error from inside the monitor characteristic call from ble-plx.We have to note that this is only when we reach the 30s timeout when the pairing code is shown. You need to be pairing a new device, ignore the pairing prompt, and reach this crash. If you feel this change introduces a performance hit (I measured and looked heavily into the
instanceof
perf and it seems pretty light) please advice for a better solution. I banged my head for two days and this is the only solution I could find that doesn't totally silence the error or hinder the functionality.As an explanation of why this is happening, my understanding is that when we create the observable outside of the transport instance or the open method, the exception thrown is unhandled and therefor breaks the application. By catching that specific error in the observable, channeling it into the
inferMTU
method, and rethrowing it from there, we get the handled error and the correct "Pairing Failed" screen instead of an app crash.In other words, without this, the error is unhandled.