Skip to content

Handle ServiceWorker lifecycle - #357

Merged
pietro909 merged 5 commits into
nextfrom
handle-sw-lifecycle
Mar 4, 2026
Merged

pietro909 merged 5 commits into
nextfrom
handle-sw-lifecycle

Conversation

@pietro909

@pietro909 pietro909 commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Depends on arkade-os/ts-sdk#329

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated arkade-os boltz-swap and SDK dependencies to latest pre-release versions.
    • Updated project configuration files.
  • Bug Fixes

    • Wallet lock now properly clears background status monitoring intervals.
  • Refactor

    • Modified service worker activation to support manual updates and streamlined cache cleanup.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 4, 2026 •

Copy link
Copy Markdown

Deploying wallet-bitcoin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1bd3a4a
Status: ✅  Deploy successful!
Preview URL: https://dcebfb55.wallet-bitcoin.pages.dev
Branch Preview URL: https://handle-sw-lifecycle.wallet-bitcoin.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • next-version

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 71b92221-5912-4855-9edb-6972b35285f3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The PR updates pre-release dependency versions, adds status ping interval cleanup to wallet lock logic, and refactors service worker activation to support skip-waiting triggering instead of forcing client page reloads.

Changes

Cohort / File(s) Summary
Configuration & Dependencies
.gitignore, package.json
Added TASKS.md to ignore entries; bumped @arkade-os/boltz-swap to 0.3.0-next.2 and @arkade-os/sdk to 0.4.0-next.4.
Wallet Provider
src/providers/wallet.tsx
Added logic in lockWallet to clear the status ping interval if it exists, preventing ongoing wallet status pings after lock.
Service Worker
src/wallet-service-worker.ts
Replaced forced client reload mechanism with a SKIP_WAITING message listener to trigger self.skipWaiting(). Activation now only performs cache cleanup and claims clients without broadcasting reload messages.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client/App
    participant SW as Service Worker
    participant Cache as Cache Storage

    rect rgba(100, 150, 200, 0.5)
    Note over Client,Cache: New Service Worker Activation Flow
    Client->>SW: Send SKIP_WAITING message
    activate SW
    SW->>SW: self.skipWaiting()
    end
    
    rect rgba(150, 200, 100, 0.5)
    Note over Client,Cache: Activation Event
    SW->>Cache: Clean up old caches
    SW->>SW: Claim all clients
    SW-->>Client: Ready for new version
    deactivate SW
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • PR #342 — Modifies the same files (package.json, src/providers/wallet.tsx, src/wallet-service-worker.ts) with overlapping changes across dependencies and wallet/service worker logic.
  • PR #316 — Updates service worker activation and reload behavior, directly related to the skip-waiting and client claim refactoring in this PR.
  • PR #309 — Bumps the same @arkade-os/sdk and @arkade-os/boltz-swap dependency versions in package.json.

Suggested reviewers

  • bordalix
  • louisinger
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Handle ServiceWorker lifecycle' accurately reflects the main changes in the PR, which focus on managing Service Worker lifecycle through SKIP_WAITING, preventing wallet status pings when locked, and updating dependencies.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch handle-sw-lifecycle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 4, 2026 •

Copy link
Copy Markdown

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1bd3a4a
Status: ✅  Deploy successful!
Preview URL: https://5d83d6a3.arkade-wallet.pages.dev
Branch Preview URL: https://handle-sw-lifecycle.arkade-wallet.pages.dev

View logs

@pietro909 pietro909 changed the title Handle sw lifecycle Handle ServiceWorker lifecycle Mar 4, 2026
@pietro909
pietro909 marked this pull request as ready for review March 4, 2026 09:21
@pietro909

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review - we're closing the circle with what was implemented her arkade-os/ts-sdk#329 to ensure the Service Worker never gets stuck across releases.

@coderabbitai

coderabbitai Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

@pietro909 Sure! I'll kick off a review of the PR now. Thanks for the context on the ServiceWorker lifecycle fix — I'll keep in mind that this builds on the work in arkade-os/ts-sdk#329 to prevent the Service Worker from getting stuck across releases.


🧠 Learnings used
Learnt from: bordalix
Repo: arkade-os/wallet PR: 114
File: src/lib/asp.ts:0-0
Timestamp: 2025-06-30T18:33:29.839Z
Learning: In src/lib/asp.ts, only the collaborativeExit function should accept both IWallet and ServiceWorkerWallet types. Other wallet functions (getBalance, getTxHistory, getReceivingAddresses, redeemNotes, sendOnChain, settleVtxos) should maintain their original IWallet-only signatures and not be updated for consistency.
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@pietro909
pietro909 requested a review from bordalix March 4, 2026 09:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/wallet-service-worker.ts (1)

14-17: Wrap skipWaiting() in event.waitUntil() to extend worker lifetime during activation.

The ExtendableMessageEvent supports event.waitUntil(promise) to keep the service worker alive while async work completes. Since skipWaiting() returns a promise that resolves once activation is attempted, wrapping it ensures the browser doesn't terminate the worker mid-transition.

Suggested patch
 self.addEventListener('message', (event: ExtendableMessageEvent) => {
   if (event.data?.type === 'SKIP_WAITING') {
-    self.skipWaiting()
+    event.waitUntil(self.skipWaiting())
   }
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/wallet-service-worker.ts` around lines 14 - 17, The message handler that
listens via self.addEventListener and checks for event.data?.type ===
'SKIP_WAITING' should call skipWaiting() inside event.waitUntil(...) so the
service worker stays alive until activation completes; update the handler for
ExtendableMessageEvent to call event.waitUntil(self.skipWaiting()) instead of
calling self.skipWaiting() directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/wallet-service-worker.ts`:
- Around line 14-17: The message handler that listens via self.addEventListener
and checks for event.data?.type === 'SKIP_WAITING' should call skipWaiting()
inside event.waitUntil(...) so the service worker stays alive until activation
completes; update the handler for ExtendableMessageEvent to call
event.waitUntil(self.skipWaiting()) instead of calling self.skipWaiting()
directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 841272ff-a047-4229-9c06-a65df9a8201a

📥 Commits

Reviewing files that changed from the base of the PR and between 8b158fe and f10bb1f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .gitignore
  • package.json
  • public/wallet-service-worker.mjs
  • src/providers/wallet.tsx
  • src/wallet-service-worker.ts

@pietro909
pietro909 merged commit b27c132 into next Mar 4, 2026
3 checks passed
@pietro909
pietro909 deleted the handle-sw-lifecycle branch March 4, 2026 11:32
@coderabbitai coderabbitai Bot mentioned this pull request May 12, 2026
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.

1 participant