fix(cli): keep blog adapter timeout active through body reads - #5286
Merged
cixzhang merged 1 commit intoSep 3, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
HelloOjasMutreja
marked this pull request as ready for review
August 21, 2026 08:47
HelloOjasMutreja
requested review from
cixzhang,
imdreamrunner and
josephfarina
as code owners
August 21, 2026 08:47
Contributor
PR Analysis Report
No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
The shared blog adapter's 15-second abort timer was cleared as soon as fetch returned response headers, leaving the later body read unbounded in time. It also buffered the entire response into memory via res.text() before checking the 5 MB limit, so the limit never actually capped how much was read. The timer now stays active through body consumption (cleared in a finally block after the read completes or fails). The body is read via its stream where available, checking decoded size after each chunk and aborting as soon as it exceeds the limit, rather than buffering the full response first. Falls back to res.text() when a runtime or test stub doesn't expose a streamable body, still enforcing the cap after the fact in that case. Also adds ReadableStream and DOMException to the CLI's ESLint global allowlist, needed for the new streaming-body test coverage.
HelloOjasMutreja
force-pushed
the
fix/cli-blog-adapter-timeout-and-size-cap
branch
from
August 31, 2026 09:28
510ec68 to
b9207f2
Compare
cixzhang
approved these changes
Sep 3, 2026
cixzhang
left a comment
Contributor
There was a problem hiding this comment.
Thanks, this is good. The stalled body now times out and the oversized stream stops early without changing the CLI error contract.
[Reviewed by Robohands]
josephfarina
pushed a commit
that referenced
this pull request
Sep 4, 2026
The shared blog adapter's 15-second abort timer was cleared as soon as fetch returned response headers, leaving the later body read unbounded in time. It also buffered the entire response into memory via res.text() before checking the 5 MB limit, so the limit never actually capped how much was read. The timer now stays active through body consumption (cleared in a finally block after the read completes or fails). The body is read via its stream where available, checking decoded size after each chunk and aborting as soon as it exceeds the limit, rather than buffering the full response first. Falls back to res.text() when a runtime or test stub doesn't expose a streamable body, still enforcing the cap after the fact in that case. Also adds ReadableStream and DOMException to the CLI's ESLint global allowlist, needed for the new streaming-body test coverage.
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.
Fixes #5249.
Problem
The shared CLI blog adapter (
packages/cli/api/blog/_adapter.mjs, used by bothblog.listandblog.detail) had two related issues infetchText:fetch()returned response headers, before reading the body. A response whose headers arrive promptly but whose body stream stalls afterward has no timeout protecting it, and the call hangs indefinitely.res.text(), which buffers the entire response into memory before the code ever checks the 5 MB limit. The limit rejects an oversized response only after it has already been fully read, so it doesn't actually cap how much data gets buffered.Fix
finallyblock after the read completes (success or failure), so it stays active through body consumption, not just through the initialfetch()call.res.body's stream where available (getReader(), decoding chunk by chunk), checking the running decoded size after each chunk and cancelling the read as soon as it exceeds 5 MB, instead of buffering the full response first. Falls back tores.text()when a runtime or test stub doesn't expose a streamablebody(rare in practice; every realfetch()response has one), still enforcing the cap after the fact in that case.Verification
Added two regression tests matching the issue's own reproduction:
fetchresolves immediately but its response body never closes. Using fake timers, advancing past the 15s timeout causes the call to reject withERR_FETCH_FAILEDrather than hang. The stub's stream reacts to the request'sAbortSignalthe way a real fetch response body does (rejects pending reads on abort), so this faithfully exercises the same mechanism a real network response uses.ERR_FETCH_FAILED, and the stub's pulled-chunk counter confirms fewer than all 5 chunks were consumed, proving the read stopped early rather than buffering the whole body before checking.Both new tests fail against the pre-fix implementation (verified by temporarily reverting just the implementation file and re-running) and pass with the fix. Full blog test suite (22 tests across
_adapter,blog,blog.detail,blog.list) passes. Lint required addingReadableStream/DOMExceptionto the CLI's ESLint global allowlist (needed by the new streaming-body test coverage; both are standard globals already implicitly relied on viafetch/AbortController). Typecheck (tsconfig.strict.json) shows no new errors; the pre-existing failures it reports are all in unrelated template/theme assets.