aboutsummaryrefslogtreecommitdiff
path: root/extensions/chrome-profile-bridge/daemon.cjs
diff options
context:
space:
mode:
authorTianren Dong <tianrendong.dtr@gmail.com>2026-05-16 13:00:48 -0400
committerTianren Dong <tianrendong.dtr@gmail.com>2026-05-16 13:00:48 -0400
commitfcae5b188baa1bdfed48208d7cfc2b711af4aae3 (patch)
tree040c6cde8b8d23d1909c7235641e6694ed170495 /extensions/chrome-profile-bridge/daemon.cjs
parent43c62c2f338654394f82c86aa12b22be6a358d94 (diff)
0.17.2: fix /next lastSeenAt + strict daemon version match
Bugs surfaced in real-world 0.17.0/0.17.1 testing: 1. Daemon /next only recorded lastSeenAt AFTER the auth/pair checks. Pre-pair the daemon returns needsPairing early without recording the poll, so connected stayed false even though the extension was polling. /chrome onboard's wait-for-poll loop spun forever on a healthy extension. Fix: record lastSeenAt at the top of /next for any chrome-extension origin, before auth checks. Onboard now correctly detects 'extension alive but unpaired' which is the precise state during pair step. 2. Daemon compatibility was checked at major.minor match. Result: a patch release fixing a daemon bug (like #1) couldn't replace the running daemon — new Pi client joins old buggy daemon as client. Fix: exact version match. Patch releases auto-kill+respawn the daemon.
Diffstat (limited to 'extensions/chrome-profile-bridge/daemon.cjs')
-rw-r--r--extensions/chrome-profile-bridge/daemon.cjs10
1 files changed, 8 insertions, 2 deletions
diff --git a/extensions/chrome-profile-bridge/daemon.cjs b/extensions/chrome-profile-bridge/daemon.cjs
index 676344f..bcd2b68 100644
--- a/extensions/chrome-profile-bridge/daemon.cjs
+++ b/extensions/chrome-profile-bridge/daemon.cjs
@@ -569,6 +569,14 @@ async function handle(req, res) {
if (!isBrowserOriginAllowed(req)) { sendJson(res, 403, { ok: false, error: "browser origin not allowed" }); return; }
const originExt = extensionIdFromOrigin(req);
const currentVersion = ARGS.version;
+ // Any /next from a chrome-extension origin counts as 'extension is alive'. We record
+ // lastSeenAt here — before the auth/pair checks below — so that /chrome onboard's
+ // connect-wait loop can detect a polling-but-unpaired extension (which is precisely
+ // the state during the pair step).
+ if (originExt) {
+ lastSeenAt = Date.now();
+ clientName = url.searchParams.get("name") ?? undefined;
+ }
if (!auth.paired) {
sendJson(res, 200, { type: "none", needsPairing: true, expectedExtensionVersion: currentVersion },
{ ...corsHeaders, "x-pi-chrome-version": currentVersion });
@@ -590,8 +598,6 @@ async function handle(req, res) {
return;
}
if (waiters.length >= MAX_WAITERS) { sendJson(res, 429, { ok: false, error: "too many pollers" }, corsHeaders); return; }
- lastSeenAt = Date.now();
- clientName = url.searchParams.get("name") ?? undefined;
let aborted = false;
let active;
req.once("close", () => { aborted = true; if (active) waiters = waiters.filter((e) => e !== active); });