-
-
Notifications
You must be signed in to change notification settings - Fork 52.5k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The chrome extension is crashing frequently, and cannot be enabled with much success, here's the bug report made by OpenClaw
🐛 Bug Analysis Report
🔴 Critical Issues
1. Missing chrome.runtime.onStartup Handler
Location: /Users/swei/.openclaw/browser/chrome-extension/background.js (line 380-383)
chrome.action.onClicked.addListener(() => void connectOrToggleForActiveTab())
chrome.runtime.onInstalled.addListener(() => {
void chrome.runtime.openOptionsPage()
})Problem:
- When Chrome restarts, the extension does NOT automatically reconnect to the relay server
- User must manually click the icon to re-attach
- No
chrome.runtime.onStartuphandler exists to auto-recover
Impact: High - Extension appears "broken" after browser restart
2. No Automatic Reconnection on WebSocket Failures
Location: Lines 45-83 (ensureRelayConnection())
Problem:
if (relayWs && relayWs.readyState === WebSocket.OPEN) return
if (relayConnectPromise) return await relayConnectPromise- Only retries via
relayConnectPromise - No background retry loop
- If WebSocket connection fails permanently (network hiccups, relay server crash), extension stays disconnected
Impact: High - Manual intervention required
3. No Error Recovery After Debugger Detach
Location: Lines 245-275
Problem:
async function onDebuggerDetach(source, reason) {
const tabId = source.tabId
if (!tabId) return
if (!tabs.has(tabId)) return
void detachTab(tabId, reason)
}- Simply detaches and removes from state
- No reconnect attempt
- If debugger detaches unexpectedly (tab navigation, Chrome crash recovery, system sleep), user must manually re-attach
Impact: Medium - Fragile user experience
4. Service Worker Suspended State
Location: manifest.json and background.js header
Problem:
// manifest.json
"background": { "service_worker": "background.js", "type": "module" }
// background.js
const DEFAULT_PORT = 18792- Service Workers in Chrome can be suspended when inactive
- Relies on
chrome.runtime.onStartupto wake up, but that handler is missing - Slight delay before auto-reconnection may be missed by WebSocket heartbeat
Impact: Low-Medium - Background state not preserved
📋 Additional Observations
- No Persistent Connection State - No localStorage/database backup of attached tabs
- No Health Check/Keep-alive - WebSocket has ping/pong but no periodic extension self-check
- Error Messages Too Silent - Errors caught by
catch { // ignore }are invisible to users
💡 Recommended Fixes
Fix 1: Add chrome.runtime.onStartup Handler
chrome.runtime.onStartup.addListener(async () => {
await ensureRelayConnection()
const [active] = await chrome.tabs.query({ active: true, currentWindow: true })
if (active?.id && !tabs.has(active.id)) {
tabs.set(active.id, { state: 'connecting' })
setBadge(active.id, 'connecting')
}
})Fix 2: Add Background Reconnection Loop
chrome.alarms.create('reconnect', { periodInMinutes: 1 })
chrome.alarms.onAlarm.addListener(async (alarm) => {
if (alarm.name === 'reconnect') {
await ensureRelayConnection()
}
})Fix 3: Add Tab Auto-reconnect on Activation
chrome.tabs.onActivated.addListener(async () => {
await ensureRelayConnection()
})Would you like me to implement these fixes?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working