A Chat cancelled while its Run opens is closed upstream, not left running.
Before, a cancel that landed after the HTTP/2 head arrived but before runOnce
subscribed to the signal was never seen ({once:true} listener added to an
already-aborted signal): the Run kept streaming upstream for nobody with its
5s heartbeat interval, and the session was never closed. open/openH2/openH1
now check the signal at each hand-off, close what arrived, and remove their
abort listeners; runOnce checks again before starting the heartbeat. HTTP/1's
write callback now waits for its BidiAppend, so backpressure and close see
the pending upload. A cancelled open answers 410 instead of 502.
Reviewed at a4e1db1b0d734c1a1b15c1fe0cafb0f9cb5313c0 (on main 5fc0a75):
- full `bun test` (isolated HOME/TMPDIR): 1288 pass, 0 fail (main: 1265/0);
`bun scripts/check.mjs` ok.
- own plugin-level test (fake HTTP/2 session, abort a microtask after the
200 head, upstream never ends): on main the request hangs, req never
closed or destroyed; at this head it answers at once, req closed once.
- broke by hand: dropping runOnce's aborted check fails "the plugin: head
abort ..."; reverting the H1 write callback to an immediate cb() fails
three openH1 append tests.
- checked: destroying the H1 Duplex with a write in flight emits no
'error' (bun and node); 410 "the request was cancelled" doesn't match
magpie's modelRetired words.
Not tried: a real Cursor account or a real proxy (offline fakes only).