Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(browser-extension): time out stalled collector requests (#828)

Rudy Mizrahi Celekli05c22dc4e55a
diff --git a/browser-extension/README.md b/browser-extension/README.md
index fae47b21..1ff7ff5b 100644
--- a/browser-extension/README.md
+++ b/browser-extension/README.md
@@ -305,8 +305,10 @@ dashboard), including interleaved sessions with no cross-contamination.
stall between chunks could drop a turn. The durable delivery queue (in `chrome.storage`) protects
everything *after* a turn is assembled, not during. Persisting partial assembler state is a
future item.
-- **Delivery retry cadence.** Retries use `chrome.alarms`, which MV3 clamps to a ~30s minimum, so
- the first retry lands at ~30s rather than the computed sub-second backoff. Fine for a
+- **Delivery retry cadence.** Each POST has a ten-second deadline, so a collector that accepts
+ a connection but never responds cannot hold the queue indefinitely. Timed-out batches remain
+ durable and follow the existing retry limit. Retries use `chrome.alarms`, which MV3 clamps
+ to a ~30s minimum, so the first retry lands at ~30s rather than the computed sub-second backoff. Fine for a
local-loopback collector that is almost always reachable; the queue guarantees eventual delivery.
- **Capture depends on `window.fetch`.** Confirmed correct for claude.ai. Sites using XHR or a page
service worker for streaming would need additional interception (deferred).
diff --git a/browser-extension/src/background/delivery.ts b/browser-extension/src/background/delivery.ts
index c00ea321..e38e3612 100644
--- a/browser-extension/src/background/delivery.ts
+++ b/browser-extension/src/background/delivery.ts
@@ -14,6 +14,7 @@ import { serial } from '../shared/serial.js';
const QUEUE_KEY = 'delivery_queue';
const ALARM = 'beacon_flush';
const MAX_ATTEMPTS = 6;
+const POST_TIMEOUT_MS = 10_000;
interface QueueItem {
id: string;
@@ -98,6 +99,9 @@ async function post(item: QueueItem): Promise<boolean> {
try {
const res = await fetch(item.endpoint, {
method: 'POST',
+ // Release the serialized queue even if a local listener never replies.
+ // A timeout follows the same durable retry path as any failed POST.
+ signal: AbortSignal.timeout(POST_TIMEOUT_MS),
headers: { 'content-type': 'application/json' },
// A loopback listener must not be able to bounce chat content elsewhere.
redirect: 'error',