From 8832be07855963dc2fc1f25d692fae8219377937 Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Fri, 15 May 2026 06:28:41 +0200 Subject: [PATCH] chore(headless): surface v2 init failure reason in fallback warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The catch block was swallowing the actual error, leaving operators with "v2 init failed, falling back to v1 string-matching" and no diagnostic to act on. Found out this session that the failure was build staleness (packages/coding-agent dist was not rebuilt by copy-resources) — would have been instant to diagnose if the reason had been logged. Now: "[headless] Warning: v2 init failed (Timeout waiting for response to init...), falling back to v1 string-matching" Co-Authored-By: Claude Opus 4.7 (1M context) --- src/headless.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/headless.ts b/src/headless.ts index 77d1c3521..83cb013db 100644 --- a/src/headless.ts +++ b/src/headless.ts @@ -1901,9 +1901,10 @@ async function runHeadlessOnce( try { await client.init({ clientId: "sf-headless" }); _v2Enabled = true; - } catch { + } catch (initErr) { + const reason = initErr instanceof Error ? initErr.message : String(initErr); process.stderr.write( - "[headless] Warning: v2 init failed, falling back to v1 string-matching\n", + `[headless] Warning: v2 init failed (${reason}), falling back to v1 string-matching\n`, ); }