8000 fix(session): bound the sensor sync wait and fail closed by shroominic · Pull Request #134 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

fix(session): bound the sensor sync wait and fail closed - #134

Closed
shroominic wants to merge 1 commit into
feature/cbio-gs1-livefrom
fix/session-sync-bounded-failure
Closed

shroominic wants to merge 1 commit into
feature/cbio-gs1-livefrom
fix/session-sync-bounded-failure

Conversation

@shroominic
Copy link
Copy Markdown
Owner

Closes #133. Stacked on feature/cbio-gs1-live.

Problem

A connected sensor that never returns a decodable frame parked setup on
"Syncing sensor history" forever. On the real SIBIONICS/CBio GS1 sensor the
link came up, FF31 notifications were enabled, one five-byte reply failed the
offline parser with reason length, and the passive timer had already been
cancelled — so no further session state arrived and the card never changed.

Change

The host now owns a bounded wait for the first readable result.

  • CgmAppController arms a 45-second deadline while a live session sits in the
    syncing stage with no decodable data.
  • When it elapses the controller publishes a terminal error snapshot carrying
    cgm.session.syncStalled, blocks automatic reconnect, and stops accepting
    further syncing snapshots until the driver reports data, an error, or a
    disconnect.
  • The connect screen renders its existing failure card with an accurate title
    and a next action: Try again / Choose another sensor.
  • Healthy paths are untouched: Libre 2 phase waits (the driver publishes its own
    terminal outcome) and in-progress history syncs (bounded, driver-owned) are
    not bounded.
  • The Cbio driver is unchanged: no new writes, no change to its fail-closed
    read discipline.

Copy

  • Title: No reading from this sensor
  • Message: This sensor didn't return a readable reading. Try again, or choose another sensor. Some sensor models are not supported yet.
  • Status text: Sensor sent no readable reading

Tests

openhealth/test/session_sync_failure_test.dart (written RED first):

  • an undecodable frame followed by silence fails closed after the deadline
  • a session that reports readable data before the deadline stays live
  • retrying after the bounded failure starts a fresh window
  • a readable frame arriving later still recovers the session
  • Libre 2 phase waits and in-progress history syncs are not bounded

Verification: ./scripts/flutter-workspace.sh test-unit green (477 openhealth
tests plus every package), analyze clean, format-check clean.

Device gap

The debug APK was rebuilt (make build-android green) and installed on the
Pixel 6, and the app was driven to the nearby-sensor scan, but the GS1 sensor
did not advertise during that window, so a live connect could not be observed
on-device. The bounded failure is covered by the widget tests above. Scan-state
completion is a separate lane tracked in #129.

A connected sensor whose frames never decode parked setup on "Syncing
sensor history" forever: the Cbio session enables FF31 notifications, one
five-byte reply fails the offline parser with reason `length`, and the
passive timer has already been cancelled, so no further state arrives.

Sessions now arm a 45-second bounded wait for the first readable result
while they sit in the syncing stage and have no decodable data. When the
deadline elapses the host publishes a terminal error snapshot carrying
`cgm.session.syncStalled`, blocks automatic reconnect, and the connect
screen shows a next action instead of a spinner. Drivers that own their
terminal outcome (Libre 2 phases) or an in-progress history sync are left
untouched, and the Cbio driver's fail-closed write discipline is
unchanged.
@shroominic
Copy link
Copy Markdown
Owner Author

Carried by the GS1 consolidation in PR #209 (branch feature/cbio-gs1, head 3eca4f4).

This PR is contained in the consolidated line; the merge that carries it is c85f827.

Closing as subsumed by the consolidation - not as won't fix. The per-defect evidence stays in this thread, and the carrying commit above is where the change now lives.

@shroominic shroominic closed this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0