2026 OpenClaw Frontend Practice:
Parse Service Worker Lifecycle & Cache Key Deltas on a Remote Mac, Then Ship a PR Summary
Audience: teams shipping service workers who fight silent cache drift in PRs. Use this remote Mac recipe inside OpenClaw: capture lifecycle edges, diff caches.keys(), write JSON artifacts, and post a Markdown PR summary with deploy-hook-grade logs. Pair with the Safari vs Chromium SW checklist, Netlify hook smoke chain, and build metrics → PR summary. Traditional Chinese version.
01 Why parse service workers from a remote Mac
Service worker truth needs real WebKit timing on Apple hardware. A remote Mac matches reviewer stacks and stays awake while OpenClaw polls navigator.serviceWorker.
Emit small JSON under .openclaw/reports/ each pass so CI, chat, and GitHub share one fact base.
02 Pain points this runbook removes
- Invisible waiting workers: reviewers only see the active worker while customers sit on an older cache until refresh.
- Key churn without semantics:
caches.keys()changes every deploy but nobody records which prefixes are safe to delete. - Chat-only debugging: screenshots disappear; you need NDJSON plus artifact paths tied to
GIT_SHA.
03 Decision matrix: where to invest automation
| Approach | Strength | Weakness | When to pick it |
|---|---|---|---|
| Manual Web Inspector | Deep breakpoints | Not reproducible across PRs | Exploration only |
| Playwright probe page | Scriptable lifecycle reads | Needs disciplined waits | Default for OpenClaw |
| Customer RUM beacons | Real user coverage | Coarse, privacy limited | Post-merge monitoring |
Pick the probe page whenever a PR touches sw.js, precache manifests, or routing tables. Pair it with the checklist article so skipWaiting and clients.claim policies stay explicit.
04 Reproducible runbook (five owner steps)
- Reserve the runner: SSH to the remote Mac,
cd ~/openclaw-runs/$PR_NUMBER, exportBASE_URLto the preview host, and pinGIT_SHA. - Install browsers once:
npx playwright install webkitso subsequent probes reuse the same WebKit bundle. - Warm twice: run a tiny shell probe that curls
$BASE_URL, sleeps eight seconds, curls again, then launches Playwright soinstallandactivateevents can fire deterministically. - Emit deltas: write
.openclaw/reports/sw_cache_delta.jsonwith sortedaddedKeysandremovedKeyscompared tobaseline/sw_cache_baseline.jsonfrommain. - Ship the summary: render
pr_sw_cache_summary.mdand POST it through your gateway withIdempotency-Key: $GIT_SHA:sw-cache:$PR_NUMBERso flaky hooks do not duplicate comments.
05 Script and probe placeholders you can paste
Save the following as scripts/openclaw/sw-cache-probe.mjs and call it from your OpenClaw task file. It is intentionally minimal so you can swap selectors per app.
// scripts/openclaw/sw-cache-probe.mjs (placeholder)
import { chromium, webkit } from 'playwright';
const base = process.env.BASE_URL;
const browser = await webkit.launch();
const page = await browser.newPage();
await page.goto(base, { waitUntil: 'networkidle' });
const snapshot = await page.evaluate(async () => {
const regs = await navigator.serviceWorker.getRegistrations();
const keys = await caches.keys();
return {
registrations: regs.map(r => ({
scope: r.scope,
activeState: r.active?.state,
waitingState: r.waiting?.state,
installingState: r.installing?.state
})),
cacheKeys: keys.sort()
};
});
console.log(JSON.stringify(snapshot));
await browser.close();
Wrap the Node call with a shell guard that exports OPENCLAW_RUN_ID and pipes stdout into tee -a .openclaw/reports/sw_probe.ndjson so failures still leave breadcrumbs.
06 Log fields, failure retries, and operator notes
Emit one NDJSON object per attempt. Use the same keys your Netlify hook runner already writes so dashboards stay uniform.
- ▸
ts,level,openclaw_run_id,git_sha,pr_number,phase(warmup|probe|diff|callback). - ▸
attempt,duration_ms,browser(webkit|chromium),cache_key_count,waiting_worker_presentboolean. - ▸
error_class(timeout|quota|assert|http),last_http_status,trace_pathfor Playwright artifacts.
Retry policy: retry read-only probes on 502, 503, 429, or TLS resets with exponential backoff starting at two seconds, jitter twenty percent, maximum five attempts. Never retry a GitHub comment POST unless the idempotency key proves the first attempt never reached the server.
07 Structured data and internal linking plan
Head JSON-LD includes BlogPosting, BreadcrumbList, HowTo, and FAQPage for rich results.
- In-links: mention this slug from the blog index and from deploy-hook posts when precache lists change.
- Locales: reuse the slug per language; publish
hreflangonly when translated HTML exists. - Anchors: keep TOC
idtargets stable for audits.
08 FAQ: storage quota and opaque responses
| Symptom | Root cause | Mitigation |
|---|---|---|
QuotaExceededError in cache.put |
Origin storage budget exhausted or too many large opaque entries. | Log quotaEstimateMb, cap precache versions, delete stale RELEASE_ID prefixes before activate finishes. |
| Audit shows “0 bytes” for CDN fonts | Opaque no-cors responses hide real size. | Track opaqueEntryCountHint separately; never compare opaque bytes to same-origin JSON bundles. |
| Summary POST keeps failing | Token scope or secondary rate limits. | Backoff with jitter, rotate OPENCLAW_GATEWAY_TOKEN, and attach only artifact URLs in the PR body. |
Prefer same-origin or CORS-enabled assets when opaque volume breaks budgets.
Rent the Mac That Hosts Honest Service Worker Evidence
Stop guessing cache regressions from Linux-only CI. Keep OpenClaw workers on a dedicated Mac, pair them with SSH and VNC guides in the help center, compare pricing without logging in, then buy or rent capacity when WebKit fidelity becomes a release gate.