Skip to content

fix(clearance): reconcile sw keepalive alarm after CDP config injection - #212

Open
ChechiDev wants to merge 1 commit into
mainfrom
fix/sw-keepalive-alarm-reconcile
Open

ChechiDev wants to merge 1 commit into
mainfrom
fix/sw-keepalive-alarm-reconcile

Conversation

@ChechiDev

Copy link
Copy Markdown
Owner

Closes #211

Problem

During real clearance smoke testing (CP-SMOKE-B), sw_keepalive_confirmed was
consistently False even after the bounded retry polling fix in v0.47.11.

Root cause: chrome.storage.onChanged does not reliably fire when storage
is written via CDP Runtime.callFunctionOn. The write succeeds (readback in
Step 5 confirms the value), but the event never dispatches to the extension SW.
This means startAlarmIfNeeded() in background.js never runs and the
swKeepalive alarm is never created.

Fix

Add Step 6 to inject_storage_config_to_extension in PydollEngine. When
enable_sw_keepalive: True is in the config, explicitly call
chrome.alarms.get("swKeepalive") + chrome.alarms.create(...) directly from
the SW CDP session before detach. This bypasses onChanged entirely — the
alarm is created within the same CDP session that writes the config.

Tests

4 new unit tests in TestPydollEngineInjectStorageConfigToExtension:

  • test_alarm_reconciliation_called_when_enable_sw_keepalive_true
  • test_alarm_reconciliation_skipped_when_enable_sw_keepalive_false
  • test_alarm_reconciliation_failure_raises_page_load_error
  • test_alarm_reconciliation_does_not_expose_secrets

All 111 unit tests pass.

Test plan

  • CI green on this PR
  • Merge + tag v0.47.12
  • Authorize and run real smoke — verify sw_keepalive_confirmed: PASS

chrome.storage.onChanged may not fire when config is written via CDP,
so startAlarmIfNeeded() never ran and swKeepalive was never created.
Step 6 in inject_storage_config_to_extension now calls chrome.alarms.get
+ chrome.alarms.create directly from the SW CDP session, bypassing the
onChanged dependency entirely.
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.

fix(clearance): reconcile sw keepalive alarm after CDP config injection

1 participant