State change (block toggle, bypass) not reflected by GET /api/state until debounced disk write completes #18

Open
opened 2026-06-18 23:42:23 +00:00 by shawn · 0 comments
Owner

Observed: PATCH /api/blocks {enabled:false} returns success immediately, but a subsequent GET /api/state shows the block still enabled. The state only updates after the 500ms debounced save writes to disk.

Root cause: _gather_channel_state() calls pm.load() which reads from disk. The PATCH handler uses _debounced_save_preset() which waits 500ms before writing. During that window, state reads return stale data.

Impact: Any quick-toggle operation (block toggle, bypass) is invisible to the UI until the debounce fires. This affects the automated test runner at speed.

Suggested fix: Either:

  1. Reduce debounce delay for state-critical changes (block toggle, bypass, volume)
  2. Add an in-memory preset cache that reflects uncommitted changes
  3. Bypass the disk read in _gather_channel_state() and use the last-loaded in-memory preset

Severity: Medium — only affects rapid reads within 500ms of a write

**Observed:** `PATCH /api/blocks {enabled:false}` returns success immediately, but a subsequent `GET /api/state` shows the block still enabled. The state only updates after the 500ms debounced save writes to disk. **Root cause:** `_gather_channel_state()` calls `pm.load()` which reads from **disk**. The PATCH handler uses `_debounced_save_preset()` which waits 500ms before writing. During that window, state reads return stale data. **Impact:** Any quick-toggle operation (block toggle, bypass) is invisible to the UI until the debounce fires. This affects the automated test runner at speed. **Suggested fix:** Either: 1. Reduce debounce delay for state-critical changes (block toggle, bypass, volume) 2. Add an in-memory preset cache that reflects uncommitted changes 3. Bypass the disk read in `_gather_channel_state()` and use the last-loaded in-memory preset **Severity:** Medium — only affects rapid reads within 500ms of a write
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shawn/pi-multifx-pedal#18