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

[DSDK-620] Fix LLD crash (race condition in transport registration) #8729

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

ofreyssinet-ledger
Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger commented Dec 18, 2024

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • Device interactions should work fine with:
      • with Ledger Device Management Kit disabled
      • with Ledger Device Management Kit enabled (ldmkTransport feature flag)
      • Speculos

📝 Description

Sentry issue: https://ledger.sentry.io/issues/6147489966/?project=6488660&query=release:2.94.0

Two things:

  • getFeature return type was any, which allowed an error to slip through: checking the value of null.enabled.
  • this was happening only in some cases, because of a race condition between:
    • the initialization of Firebase
    • the registration of transport modules

The result is a crash that would have looked like this for a user:
Screenshot 2024-12-18 at 10 29 07

The fix:

  • typing getFeature to return Feature | null.
  • all transport modules are registered at initialization, with a more dynamic logic to choose which transport to use whenever withDevice is called. This is not really a new logic, withDevice has been conceived to work like this.

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@ofreyssinet-ledger ofreyssinet-ledger requested review from a team as code owners December 18, 2024 09:35
Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 10:50am
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 10:50am
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 10:50am
web-tools ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 10:50am

@live-github-bot live-github-bot bot added desktop Has changes in LLD common Has changes in live-common labels Dec 18, 2024
@live-github-bot live-github-bot bot added the mobile Has changes in LLM label Dec 18, 2024
Copy link
Contributor

@beths-ledger beths-ledger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much needed type safety here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Has changes in live-common desktop Has changes in LLD mobile Has changes in LLM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants