fix: Honor research transport deadlines - #6
Merged
Merged
Conversation
Member
Author
|
Follow-up commit pins undici 7.29.1 instead of 7.29.0: 7.29.1 (2026-09-04) is a security release (GHSA-w293-vg96-wgc3, GHSA-rfgv-xxqx-mfg5, GHSA-3wwx-pv8p-q78v). None of the affected code paths (BalancedPool, WebSocket, permessage-deflate) is used by the CLI, but a public npm package should not pin a version with open high-severity advisories. Re-verified locally on the bumped lockfile: pnpm check passes (118 tests, coverage thresholds met) and the 305-second wall-clock smoke passes (old transport fails at ~300 s, fixed transport completes at ~305 s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by @wagnercosta
What / why
Buffered DeepNews research has a 900,000 ms (15-minute) CLI budget, but the unconfigured transport can expire while waiting for headers or body data after 300,000 ms.
undici@7.29.1and a request-scoped Agent/interceptor. Set finiteheadersTimeoutandbodyTimeoutat dispatch time, after native fetch has constructed its options, so request-level values cannot override the effective CLI budget.Validation
pnpm install --frozen-lockfile --ignore-scriptspnpm check: lint, strict types, 118 tests passed, 3 intentionally skipped (2 live tests and the opt-in long local smoke). Coverage thresholds pass.pnpm build:bundle: passed, using the committed schema. The broaderpnpm buildrefreshes the live schema and was intentionally not used for this transport-only change.Node 22.15.0 / bundled Undici 6.21.2: 35 focused tests passed. Node 24.19.0 / bundled Undici 7.29.0: full suite and actual 305-second smoke passed.
Real loopback server, four concurrent requests, no fake clock:
UND_ERR_HEADERS_TIMEOUTat 300.762 sUND_ERR_BODY_TIMEOUTat 300.757 sBoth fixed calls retain the default 900-second research budget. Reproduce with:
ASKNEWS_LOCAL_TIMEOUT_SMOKE=1 pnpm exec vitest run test/integration/http-timeout.integration.test.ts -t wall-clock(outer process budget ≥360 seconds).Short real-transport tests inspect actual dispatched values and cover true total expiry despite body chunks, delayed/stalled bodies, SSE comment heartbeats and idle aborts, closed sockets, 401-only retry, and error distinctions. Mock tests exercise conflicting fetch-supplied timer values and cleanup. Dispatch and cleanup regressions fail against the unchanged
mainimplementation and pass with this change.Built CLI against loopback: original Reddit research flags still use
POST /v1/chat/deepnews, with model/stream flags omitted; flag-over-environment timeout precedence and exits 0/4/5/6 verified.Native-fetch caveat: larger Agent defaults alone are honored on the tested Node 24 runtime; the interceptor does not assume otherwise. It explicitly wins over request-level timers if supplied, verified with a conflicting-options test.
Risk / boundaries
mainfeeds release-please; merging its separate Release PR tags/publishes. This PR does not merge, release, tag, or publish anything.CI
Node 24 compatibilityjob (typecheck, tests, bundle) so the npmundicidispatcher ↔ bundled-fetch contract is exercised on both supported Node majors. Both jobs pass on this branch.