Skip to content

Tester reads long attempts: attempt inspect reads traces over 75 MiB by byte range - #1740

Closed
Matt Kleinsmith (MattKleinsmith) wants to merge 6 commits into
mainfrom
mattk/ranged-trace-reads
Closed

Matt Kleinsmith (MattKleinsmith) wants to merge 6 commits into
mainfrom
mattk/ranged-trace-reads

Conversation

@MattKleinsmith

@MattKleinsmith Matt Kleinsmith (MattKleinsmith) commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Overview of Problem

qawolf attempt inspect refuses any trace over 75 MiB, so Tester loses the timeline, actions, snapshots, and screenshots of long attempts, including the "what the test expects" picture from a flow's last pass.

Overview of Changes

Traces over 75 MiB are now read by HTTP byte range: the zip's central directory, then only the entries the command needs. On a real 391 MB trace, --timeline reads 16 MB and one --screenshot reads 16 MB, where main reads nothing and answers too-large.

Over 75 MiB, the CLI range-reads only the zip directory and the entries it needs, about 16 MB of a 391 MB trace

Traces at or under 75 MiB keep the current single GET and JSZip path, unchanged. Moving small traces to range reads too would save bytes on --timeline, but it adds round trips where the summary reads most files anyway, and keeping one path untouched keeps every existing test on it. That can be a follow-up once this path has run for a while.

How it works
  • downloadTrace still makes one GET. Over the limit, it cancels the body, sends a 1-byte Range probe to learn the size and prove range support, and returns a ranged artifact holding a range-reader function. The parser never sees the URL.
  • The parser reads a trace through a small TraceArchive (names, has, read with a byte limit). JSZip backs it for whole files; a new range-read zip reader in parser/zip/ backs it for large ones (zip64, stored and deflate, CRC-32 checked, bounded inflate). Projection code changed only where it touches the archive.
  • Bounds: central directory at most 16 MiB and 200,000 entries; at most 75 MiB fetched per command; each entry capped at the existing per-entry limits, with its declared size enforced against decompression bombs. A huge single event file or screenshot still reads as incomplete or too-large.
  • Every request has its own abort, so a refused download closes its connection (under Bun, cancelling the body alone kept downloading in the background). A server that ignores Range fails the read as too-large, as today. 401/403, 404, 416, short reads, and timeouts map to the existing statuses, and a failed entry read reports that status rather than calling the trace malformed.

Testing

Real check, against a 391,325,377-byte trace from a 3-hour test run in our own workspace, counting bytes from storage:

  • --timeline: 15,962,949 bytes in 10 range requests (4% of the file), traceStatus: ready.
  • one --screenshot ... --output-file: 16,001,521 bytes in 12 range requests; wrote a valid 800x450 JPEG of the run page. The rest is the trace's 14 MB event file and the directory; the image itself is 38 KB.
  • --network (5,038 requests): 32.7 MB; reports incomplete, because its .network file exceeds the existing per-entry limit, as the whole-file path would.
  • Same attempt on main: traceStatus: too-large.
  • A 21.7 MB trace still takes one whole GET, unchanged.

Unit tests use generated zips, nothing large committed: ranged and whole-file paths give identical summary, timeline, action, network, request, console, and screenshot output (including on the Playwright 1.64 fixture); a zip64 screenshot round trip; an end-to-end 76 MiB archive through downloadTrace and the parser with a fake fetch that honors Range; and each bound (directory too big, too many entries, fetch budget, bad CRC, decompression bomb, impossible sizes, a server ignoring Range, every failure status).

bun run typecheck
bun run lint
bun run format:check
bun run knip
bun run test
bun run build

Not proven yet: how long a large trace takes from Tester's pods. Locally, storage served about 0.5 MB/s, so --timeline took 30 seconds; all range reads for one command share one 2-minute deadline that starts at the first range read, so a command that reads more than about 60 MB at that speed would time out.

Post-Release Tasks

  • Merge the Version Packages PR so this ships to npm. Tester's ai-task image installs @qawolf/cli@latest when it is built, so Tester gets this from the next ai-task image build after the release.

Checklist

  • Changes follow the code style of this project
  • Self-review completed
  • Tests added/updated (or not applicable)
  • No breaking changes (or described below)

Reads the end of central directory, zip64 records, and the central
directory with a few range reads, then reads one entry at a time with
CRC-32 checks, a bounded inflate, and a total fetch budget.
The trace projections now read entries through a small archive type
with two backings: JSZip for a downloaded trace, unchanged, and the
byte-range zip reader for a trace too large to download.
A trace over the download limit used to come back too-large. After the
whole-file download stops at the limit, a one-byte range probe learns
the size and proves storage honors Range, and the parser then fetches
only the directory and the entries the command reads.
Under Bun, cancelling a response body keeps the connection draining the
whole object. Each request now aborts its own controller once its body
is read or refused. The range reads' shared two-minute deadline starts
at the first read, not at the size probe, so the summary's log
downloads and the parser import no longer spend it. A partial response
longer than the range asked for is unavailable, not too-large.
A timed-out, expired, or missing range read used to look like a corrupt
entry, so the trace read as malformed and a screenshot as missing. A
failed read now carries its storage status: the trace takes it when an
event or stacks file cannot be read, a screenshot or response body
reports it, and network files read so far are marked incomplete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant