Skip to content

fix(bitbox): coalesce overlapping scan ticks onto a single init()#683

Open
joshuakrueger-dfx wants to merge 1 commit into
RealUnitCH:developfrom
joshuakrueger-dfx:joshua/fix-657-p7f1-init-coalesce
Open

fix(bitbox): coalesce overlapping scan ticks onto a single init()#683
joshuakrueger-dfx wants to merge 1 commit into
RealUnitCH:developfrom
joshuakrueger-dfx:joshua/fix-657-p7f1-init-coalesce

Conversation

@joshuakrueger-dfx
Copy link
Copy Markdown
Collaborator

Addresses Issue #657 — Part 7, finding F1 (HIGH).

Problem

connectToBitbox guarded re-entry only with state is BitboxConnecting. Once the flow moved past that state (BitboxCheckHash) while the init future was still pending, a late 500 ms scan tick re-entered connectToBitbox and started a second init() on the shared BitBox SDK manager — undefined behaviour that wedged pairing (Big-Brother analysis confirmed the state guard alone is defeated).

Fix

Extend the guard: if (state is BitboxConnecting || _pendingInit != null) return;_pendingInit covers the whole connect window and is cleared on failure/close, so genuine retries still pass. Minimal, additive, happy path unchanged.

Tests (RED→GREEN, proven, device-free)

New regression: a late connectToBitbox while init is pending must not call service.init again (verifyNever) and leaves BitboxCheckHash intact — fails on the old code (verified). Full suite green including test/integration/connect_bitbox_flow_test.dart (the replug/re-attach contract), flutter analyze clean.

🤖 Big Brother fleet analysis + operator hand-finish. Ref #657.

connectToBitbox guarded re-entry only with `state is BitboxConnecting`. Once
the flow moved past that state (BitboxCheckHash) while the init future was
still pending, a late 500ms scan tick re-entered connectToBitbox and started a
SECOND init() on the shared BitBox SDK manager — undefined behaviour that
wedged pairing.

Extend the guard with `_pendingInit != null`, which covers the whole connect
window. _pendingInit is cleared on failure/close, so genuine retries after a
failed attempt still pass the guard.

Regression (device-free): connect_bitbox_cubit_test.dart — a late
connectToBitbox while init is pending must not call service.init again
(verifyNever) and leaves the BitboxCheckHash state intact.

Issue RealUnitCH#657 — Part 7, finding F1 (HIGH).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant