How a Chrome Manifest V3 Lifecycle Bug Silently Kills WebSocket Connections
Chrome's Manifest V3 replaced persistent background pages with service workers that are automatically terminated after roughly 30 seconds of inactivity, causing WebSocket connections hosted there to drop without any error or warning. A developer building a live planning-poker extension for GitHub discovered this when users reported votes mysteriously stopping mid-session. The WebSocket had been moved to the background service worker to bypass GitHub's strict Content Security Policy, which blocked direct connections from content scripts, especially on Firefox. The silent disconnection was not a network failure but a browser lifecycle issue, as Chrome does not count an open socket as meaningful activity. The fix involves three measures: a heartbeat to keep the service worker awake, an auto-reconnect mechanism that fetches a fresh state snapshot on drop, and defensive error handling around every port message to account for the worker dying mid-execution.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in