Repository navigation
Description
mcpx(plugin): goDurationMs returns Infinity for overflow durations Go rejects — one typo'd MCPX_PLUGIN_DISCOVERY_RETRY disables daemon rediscovery for the whole session
Summary
goDurationMs (pkgs/mcpx/plugin/opencode/mcpx/daemon.ts:93-110) is the plugin's
re-implementation of Go's time.ParseDuration spelling, used for exactly one setting:
discoveryRetryMs: goDurationMs(env.MCPX_PLUGIN_DISCOVERY_RETRY) ?? TUNING.missCooldownMs
(pkgs/mcpx/plugin/opencode/mcpx-session.ts:196). The settings registry declares
plugin.discoveryRetry as KindDuration (pkgs/mcpx/internal/settings/plugin.go:49,
default 1m0s), and the Go side validates duration values with time.ParseDuration
(pkgs/mcpx/internal/settings/value.go:500), which errors on overflow (any duration
past ~2^63 ns ≈ 2562047h47m16s).
The plugin's parser has no overflow check: it multiplies Number(m[1]) * unit and only
rejects the input when the matched length differs from the input length. A long digit
string parses to Infinity and is returned as a valid duration.
Evidence (verified this run, main 5a34fa7, sandbox Bun probe importing the real daemon.ts)
"60s" => 60000 "1m30s" => 90000 "500ms" => 500
"3000000h" => 10800000000000 (finite, but Go: ParseDuration overflow error)
"1000…0h" (370 digits) => Infinity
"999…9s" (401 digits) => Infinity
"0" => undefined (Go: ParseDuration("0") == 0, valid — plugin treats it as absent)
Why it matters
mcpx-session.ts:249 gates rediscovery on Date.now() - missedAt < settings.discoveryRetryMs.
With discoveryRetryMs = Infinity (or any absurd-but-finite value Go would have rejected,
e.g. 3000000h), that comparison is true forever after the first discovery miss: a daemon
started later in the session is never discovered until the editor restarts — the exact
failure the cooldown exists to recover from, inverted, with no diagnostic anywhere. The
function's own doc comment states the design rule it violates: anything not understood is
treated as absent "because a cooldown of NaN would retry forever" — Infinity is the mirror
failure (never retry) and slips through precisely because the guard only thinks about NaN.
Secondary divergence in the same function: "0" is a valid Go duration (== 0, retry
immediately) but the plugin returns undefined for it (matched length 0), so an operator
who sets MCPX_PLUGIN_DISCOVERY_RETRY=0 silently gets the 60s default instead.
Acceptance criteria
goDurationMsreturnsundefinedfor any input whose total would exceed what Go's
time.ParseDurationaccepts (overflow → absent, matching the function's stated rule);
the result is always finite when defined.- Parity tests in
daemon.test.ts(the existinggoDurationMsdescribe block) cover:
overflow digit strings ("9".repeat(400) + "s","3000000h"),"0"(whatever behavior
triage pins — Go parity says0), plus the already-covered happy paths unchanged. - No behavior change for ordinary durations (
60s,1m30s,500ms,1.5h, negatives
staying absent is fine — that divergence is deliberate and documented in the header).
Activity
developing-today commentedon Oct 29, 2026
CODE-1161
dezren39 commentedon Oct 29, 2026
agent-note:v1
state: filed
agent: new-issue-creator-code-b
Found via: filed this run — verified with a sandbox Bun probe importing the real goDurationMs from pkgs/mcpx/plugin/opencode/mcpx/daemon.ts (main 5a34fa7): overflow digit strings return Infinity and "3000000h" returns 1.08e13, both of which Go's time.ParseDuration rejects (settings validation, internal/settings/value.go:500); "0" returns undefined although Go parses it as 0. With discoveryRetryMs = Infinity, the miss gate at mcpx-session.ts:249 never expires, so a daemon started after the first miss is never rediscovered this session. NOT self-solved: the overflow ceiling (Go's exact 2^63ns bound vs a simpler finite check) and the "0" ruling are triage's pin. Dedup: gh searches for goDurationMs / discoveryRetry — no parsing-parity hit (#1858 v2 port, #1883 sources, #1855 docs are distinct).
6 remaining items
dezren39 commentedon Oct 31, 2026
agent-note:v1
state: picked-up
task: 4326 (lane E)
note: Implementing the pinned fix: goDurationMs ceiling (non-finite or > (2^63-1)ns total -> undefined) and bare '0' -> 0, with plugin regression tests.
dezren39 commentedon Oct 31, 2026
agent-note:v1
state: parked
task: 4326 (lane E)
pr: #3090 @ 9e2abc6
note: Implemented per pinned semantics: non-finite or > (2^63-1)ns total -> undefined; bare 0 -> 0; valid spellings unchanged; negatives unchanged. bun test mcpx/daemon.test.ts on laptop: 24 pass, 0 fail. Parked for CI + Codex review on PR 3090; resume: CI green + Codex clean -> merge -> close this issue.
dezren39 commentedon Oct 31, 2026
agent-note:v1
state: parked
task: 4326 (lane E resume)
pr: #3090 @ 9e2abc6
note: Re-verified fresh: Codex review on 9e2abc6 completed clean (no findings, no review threads). CI checks still pending after a ~5-minute poll (mcpx-docs build, basic lint, basic plugin tests, stress PR tests — runs 41210003336/41210003344, fleet runner backlog). Prior verification stands: bun daemon.test.ts 24 pass on laptop.
resume: checks green -> merge 3090 -> close #2309 -> complete fixed_merged
Merge pull request #3090 from developing-today/queue/4326-2309-godura…
dezren39 commentedon Oct 31, 2026
🤖 Agent note · done