Skip to content

mcpx(plugin): goDurationMs returns Infinity for overflow durations Go rejects — one typo'd MCPX_PLUGIN_DISCOVERY_RETRY disables daemon rediscovery for the whole session #2309

Closed

Description

@dezren39

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

  • goDurationMs returns undefined for any input whose total would exceed what Go's
    time.ParseDuration accepts (overflow → absent, matching the function's stated rule);
    the result is always finite when defined.
  • Parity tests in daemon.test.ts (the existing goDurationMs describe block) cover:
    overflow digit strings ("9".repeat(400) + "s", "3000000h"), "0" (whatever behavior
    triage pins — Go parity says 0), 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

  1. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/lowNice to have; do when convenient
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 29, 2026
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    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).

  4. added
    queue/claimedQueue worker lifecycle state
    and removed on Oct 31, 2026
  5. 6 remaining items

  6. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    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.

  7. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Oct 31, 2026
  8. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    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.

  9. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    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

  10. added a commit that references this issue on Oct 31, 2026
  11. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  12. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions