Skip to content

The Service Worker Lifecycle Bug #11

@Aryan-B-Parikh

Description

@Aryan-B-Parikh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions