fix: cancel the discarded proxy stream, refresh revocation docs (#2319 round 8)

The /api/fetch route classifies an event-stream or NDJSON response as a
stream and then answers with JSON and no body — so nobody downstream
owns the upstream stream and nothing will ever read it, while the
`finally` clears the only deadline on the way out. It is now cancelled
explicitly, best-effort, the way `releaseBody` in oidcDiscoveryCompat
already does. Measured, undici reclaims an unread body here on its own,
so this is belt and braces rather than a demonstrated leak — kept
because relying on that is an implementation detail of the fetch
beneath us, not a contract. The route test and the source comment both
say so rather than implying a stronger claim.

Forwarding the signal also made revocation.ts's rationale stale: it
still described a proxy that drops `init.signal` and a backend that
cannot cancel. Both comments there, and the matching one in
revocation.test.ts, now describe the post-#2319 path — the signal
cancels, the race guarantees, and what the race is still for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YFnM6RqB4nXqNysgUYmjmq
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-09-11 04:00:44 -04:00
commit a452305204

View file

@ -393,11 +393,11 @@ describe("revokeToken", () => {
});
});
// The web fetch is `createRemoteFetch`, which re-issues the call as a POST to
// `/api/fetch` and drops `init.signal`; the backend's outbound fetch gets no
// signal either. A signal-only bound is therefore inert on exactly the path
// the timeout exists for, so the deadline has to hold against a fetch that
// ignores the signal entirely.
// The signal reaches every path since #2319 — `createRemoteFetch` forwards it
// onto the `/api/fetch` hop and that route composes it into its outbound
// fetch — but a signal-only bound is still only as good as the fetch beneath
// it. A `fetchFn` that ignores `AbortSignal`, or a wedged backend, would
// leave a signal-only deadline inert, so it has to hold without one.
it("gives up on a fetch that never settles and ignores the signal", async () => {
const outcome = await revokeToken({
endpoint: REVOKE_URL,