Skip to content

fix(clearance): start keepalive when extension config changes - #204

Merged
ChechiDev merged 1 commit into
mainfrom
fix/extension-config-onchanged-keepalive
Sep 13, 2026
Merged

ChechiDev merged 1 commit into
mainfrom
fix/extension-config-onchanged-keepalive

Conversation

@ChechiDev

Copy link
Copy Markdown
Owner

Summary

  • Adds chrome.storage.onChanged.addListener so the extension reacts to config injected by the harness after browser lifecycle events have already fired
  • Module-level CONFIG_CHANGE_KEYS Set covers all relevant keys (enable_sw_keepalive, work_server_url, work_server_token, allowed_clearance_domain, disable_task_polling, fatalStop)
  • Reconciles keepalive alarm (swKeepalive) immediately after config injection — no longer requires a browser restart to take effect
  • Does not call pollNextTask() or POST clearance — config reload only
  • In-flight guard prevents concurrent reactions from multi-key storage writes
  • try/catch/finally with console.error + persistStatus("err") on failure

Root cause

startAlarmIfNeeded() ran only at onInstalled/onStartup. At those lifecycle moments, the harness has not yet injected config, so enable_sw_keepalive is false — alarm never created. The sw_keepalive_confirmed gate (v0.47.7) confirmed this by blocking immediately after config injection.

Test plan

  • 13 new TestStorageOnChanged tests: listener registered, async, area filter, loadConfig call, startAlarmIfNeeded call, ordering, error handling, no poll, no fetch, relevant keys including work_server_token and allowed_clearance_domain (membership in CONFIG_CHANGE_KEYS block, not whole-file presence), no raw value logging
  • Full extension test suite (58 tests) passes
  • Ruff + flake8 clean
  • No real smoke executed

Closes #203

@ChechiDev ChechiDev added the type:bug Bug fix label Sep 13, 2026
@ChechiDev
ChechiDev merged commit 9bf62a8 into main Sep 13, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(clearance): start keepalive when extension config changes

1 participant