Cause: the fake agent counted runs++ when the server's "stream" event
fired. In the region test the first Run stalls (mode "stall"), the plugin
gives up at H2.wait and goes on over HTTP/1.1, and the test then sets
mode "answer". On a loaded machine the server can read the stalled Run's
HEADERS only after that switch, so the stale stream was taken as a second
Run: ag.runs 2, expected 1. "Runs kept on HTTP/1.1 try HTTP/2 again once
H2.retryAfter has passed" has the same stall-then-answer shape. The plugin
is right; the fake miscounted. A Run now counts once its first message
arrives (the plugin writes it only after the head, so a stream whose
client gave up never brings one), and a stream already destroyed when it
is read isn't answered.
Run on macOS arm64, bun 1.4.2:
- Injected: the fake held the first stream and emitted it the moment the
test set mode "answer". origin/main's test: red, Expected 1 Received 2,
the issue's output. With this change: green. The retryAfter test under
the same injection: red on origin/main, green now.
- Loaded: 8 parallel `bun test --rerun-each 15 packages/cursor/http1.test.mjs`
at load average ~50: 8 x 240 pass, 0 fail.
- `HOME=$(mktemp -d) bun test` from the root: 1920 pass, 0 fail.
`bun scripts/check.mjs`: ok.
Test-only, no version bump.
Where a proxy or network blocks HTTP/2, a Cursor Run goes over HTTP/1.1 on api2: RunSSE down, a BidiAppend for each client message up. A failure that says HTTP/2 itself can't be had keeps later Runs on HTTP/1.1 for 10 minutes; a refused connection or a reset stream falls back for that Run only. Reviewed at f5c11b7, merged onto 0437abb: cursor 66 pass, whole repo 1026 pass, check.mjs all 15; each guarded piece broken by hand turns http1.test.mjs red.