keploy / keploy/browser-extension

The Service Worker Lifecycle Bug

Open
#11 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
16
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Title: [Bug] Background Service Worker terminates prematurely due to setInterval (Manifest V3)

Description

In src/background/index.js, the extension uses setInterval to continuously poll the Keploy server /health endpoint. Because this extension uses Manifest V3, the background script runs as a Service Worker. Chrome aggressively terminates Service Workers after a short period of inactivity (usually 5 minutes). When the Service Worker sleeps, the setInterval is killed, and the extension silently stops polling and communicating with the Keploy server.

Steps to Reproduce
  1. Install the extension and load it into Chrome.
  2. Leave the browser idle for about 5-10 minutes.
  3. Check the extension's background service worker logs.
  4. Notice that the polling has stopped because the service worker was suspended.
Expected Behavior

The background script should reliably poll the server or maintain connection regardless of the Service Worker lifecycle.

Proposed Solution

Replace the setInterval logic with the chrome.alarms API, which is explicitly designed to wake up Manifest V3 Service Workers at designated intervals. Alternatively, establish a persistent WebSocket connection.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/background/index.js by tracing the setInterval-based /health polling and review the Manifest V3 service-worker lifecycle behavior. Reproduce the failure by leaving the extension idle for 5–10 minutes and checking the background service worker logs. Done means polling resumes reliably after service-worker suspension; the issue leaves chrome.alarms versus a persistent WebSocket as an unresolved design choice.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.