fix: prime bypasses the stale service worker; never saves an empty capture
After the 2026-11-10 Wodify redeploy, prime captured zero actions and every query reported NOT PRIMED. It looked like another endpoint move. It was not: every allowlisted path and response shape is unchanged. The app's service worker was serving the old OutSystems runtime to pages running the new screen code. That mixed app throws in Controller.callServerDataSource before any data action is sent, so there was nothing to observe. Measured per tab setting: bypassing the service worker alone fixes it; disabling the HTTP cache alone does not. - cdp.open_page: Network.setBypassServiceWorker on the prime tab. Per-tab, nothing in the profile is unregistered or cleared. - cdp.close: close the tab the session opened. Every prime leaked one. - prime: refuse to save a capture with no actions, leave the existing cache alone, and say why. Page errors are collected and reported, which is what separates "the browser's copy of the app is broken" from "Wodify moved its endpoints". - Skill/: the cron prompts applied the generic exit-code table to `list` commands. For `list`, 3 is session expired, 4/5 are stale / not primed, 6 is an unindexed class id. Exit 5 was not handled at all. Also document the `waitlist` value of the YOU column. - CLAUDE.md / README: record the diagnosis, the measurements, the Firebase red herring, and both exit-code tables. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
cd7924d890
commit
a15efa0874
9 files changed
+498
-16
No files matched your search
@@ -139,3 +139,92 @@ async def test_call_on_target_without_attachment_raises(session):
|
||||
with pytest.raises(RuntimeError, match="no page target"):
|
||||
await s.call("Page.navigate", on_target=True)
|
||||
await s.close()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# page lifecycle
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
class PageWS(FakeWS):
|
||||
"""Replies with the ids open_page needs."""
|
||||
|
||||
async def send(self, raw):
|
||||
msg = json.loads(raw)
|
||||
self.sent.append(msg)
|
||||
result = {"Target.createTarget": {"targetId": "TAB1"},
|
||||
"Target.attachToTarget": {"sessionId": "SESS1"}}.get(msg["method"], {})
|
||||
await self._out.put(json.dumps({"id": msg["id"], "result": result}))
|
||||
|
||||
|
||||
def _sent(ws, method):
|
||||
return [m for m in ws.sent if m["method"] == method]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_open_page_bypasses_the_service_worker_by_default():
|
||||
"""After a Wodify redeploy the app's service worker can keep serving the
|
||||
old runtime to new screen code; that app throws before sending any data
|
||||
action. Priming must bypass the worker -- for this tab only."""
|
||||
ws = PageWS()
|
||||
s = cdp.CDPSession(ws)
|
||||
s.start()
|
||||
await s.open_page()
|
||||
|
||||
worker = _sent(ws, "Network.setBypassServiceWorker")
|
||||
assert [m["params"] for m in worker] == [{"bypass": True}]
|
||||
# Scoped to the attached tab, never browser-wide.
|
||||
assert worker[0]["sessionId"] == "SESS1"
|
||||
# Bypass, not destroy: nothing is unregistered or cleared in the profile.
|
||||
assert not [m for m in ws.sent
|
||||
if any(w in m["method"].lower() for w in ("clear", "unregister", "delete"))]
|
||||
await s.close()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_open_page_can_opt_out_of_fresh_load():
|
||||
ws = PageWS()
|
||||
s = cdp.CDPSession(ws)
|
||||
s.start()
|
||||
await s.open_page(fresh=False)
|
||||
assert not _sent(ws, "Network.setBypassServiceWorker")
|
||||
await s.close()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_close_closes_the_tab_it_opened():
|
||||
"""Every prime used to leave its tab open in the profile forever."""
|
||||
ws = PageWS()
|
||||
s = cdp.CDPSession(ws)
|
||||
s.start()
|
||||
await s.open_page()
|
||||
await s.close()
|
||||
assert [m["params"] for m in _sent(ws, "Target.closeTarget")] == [{"targetId": "TAB1"}]
|
||||
assert ws.closed
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_close_without_a_page_closes_nothing(session):
|
||||
s, ws = session
|
||||
await s.close()
|
||||
assert not _sent(ws, "Target.closeTarget")
|
||||
assert ws.closed
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_close_survives_a_failing_tab_close():
|
||||
class Failing(PageWS):
|
||||
async def send(self, raw):
|
||||
msg = json.loads(raw)
|
||||
if msg["method"] == "Target.closeTarget":
|
||||
self.sent.append(msg)
|
||||
await self._out.put(json.dumps(
|
||||
{"id": msg["id"], "error": {"message": "no such target"}}))
|
||||
return
|
||||
await super().send(raw)
|
||||
|
||||
ws = Failing()
|
||||
s = cdp.CDPSession(ws)
|
||||
s.start()
|
||||
await s.open_page()
|
||||
await s.close() # must not raise
|
||||
assert ws.closed
|
||||
Reference in new issue
Block a user