chore(headless): surface v2 init failure reason in fallback warning
Some checks are pending
CI / detect-changes (push) Waiting to run
CI / docs-check (push) Blocked by required conditions
CI / lint (push) Blocked by required conditions
CI / build (push) Blocked by required conditions
CI / integration-tests (push) Blocked by required conditions
CI / windows-portability (push) Blocked by required conditions
CI / rtk-portability (linux, blacksmith-4vcpu-ubuntu-2404) (push) Blocked by required conditions
CI / rtk-portability (macos, macos-15) (push) Blocked by required conditions
CI / rtk-portability (windows, blacksmith-4vcpu-windows-2025) (push) Blocked by required conditions

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) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-15 06:28:41 +02:00
parent 996b82001f
commit 8832be0785

View file

@ -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`,
);
}