Repository navigation
fix: stream release and compression edges (#232, #230) - #242
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
- releaseLock() recomputes backpressure after dropping the released writer's queued writes, so a new writer's ready resolves while the start gate is still open (#232). - A non-released writer reports the queue formula for desiredSize while the stream is erroring, matching workerd's -1 (#232). - Gzip members are framed in Rust: the optional header CRC (FHCRC) is verified, the trailer's CRC-32 and ISIZE are checked on the push that completes each field, a member that never completes reports the incomplete-data error on close, and trailing bytes are their own error (#230). - CompressionStream and DecompressionStream accept string chunks as UTF-8 and undefined as an empty chunk, with workerd's byte-stream TypeError (#230). - An abort() racing a compression push waits for it: the push failure is the error closed reports, and abort() resolves. A deferred write that settles on an already-erroring stream keeps the stored error instead of replacing it with undefined (#230). - releaseLock() on a closed compression writable is a no-op, as on workerd's internal streams (#230). - The differential gate gained nine cases, and the stream-edges conformance test pins the stored error across a cancel and an abort.
ea6f9a4 to
db7b571
Compare
|
Round 1 findings, all three fixed on
Verification on |
Fixes the release and compression stream edges found while reviewing #229. Measured against workerd 1.20261121.1; every case below is pinned by a differential case.
Closes #232
Closes #230
#232 —
releaseLock()before the start gate settlesreleaseLock()clearedqueue/queueSizebut leftbackpressureset, so a writer created before the writable'sstartgate settled keptreadypending forever. It now recomputes backpressure after the drop, andreadyresolves as on workerd. One correction to the issue text: workerd does reject the released writer's queued write with the releasedTypeErrorand drop it (the chunk never reaches the sink); the gate case pins that measured behaviour.A non-released writer's
desiredSizenow reports the queue formula while the stream is erroring —-1with two writes outstanding athighWaterMark1,0with one — instead ofnull; only the fullyerroredstream answersnull.#230 — compression stream edges
finish(), so a missing trailer and a wrong checksum were the same error, a bad checksum surfaced onclose()instead of on the push that carried it, and bytes past the member were a generic failure.GzipDecode(flate2::Decompressraw +flate2::Crc) validates magic/CM/FLG as those bytes arrive, verifies the optional header CRC (FHCRC, RFC 1952's low 16 bits), checks the trailer's CRC-32 and ISIZE on the push that completes each field, reportsCalled close() on a decompression stream with incomplete dataonclose()when the member never ended, andTrailing bytes after end of compressed datapast the member.zlib/deflate-rawkeep flate2's writers: they already match.undefinedis an empty chunk, with workerd'sThis TransformStream is being used as a byte stream, …type error for anything else.abort()racing a compression push is deferred behind it: the parked write runs, its push failure is the errorclosedreports, andabort()resolves. A deferred write that settles on a stream that is already erroring keeps the stored error instead of replacing it withundefined.releaseLock()on a closed compression writable is a no-op, as on workerd's internal streams: the stream stays locked anddesiredSizestays 0.Tests
Nine new gate cases, each failing on the 0.2.9 binary (fail-before):
writable-release-before-startreadyresolves; queued write dropped with the released errorwritable-erroring-desired-size-1/0while erroring,nullwhen erroredcompression-string-chunksundefinedchunks, workerd's byte-stream TypeErrorcompression-truncated-closecompression-abort-racing-pushcompression-release-after-failurereleaseLock()no-op on a closed internal writablecompression-gzip-header-crccompression-trailer-splitcompression-cancel-then-abortclosedkeeps a stored error across cancel + abort (undefinedbefore)The last three were re-run against the previous head (
ea6f9a4) and diverge there. Rust tests:gzip_frames_report_workerd_outcomes(zlib.rs) for the three gzip outcomes and the native table release, andcompression_cancel_then_abort_keeps_the_stored_error(stream_edges_conformance.rs) for the exact rejection reason.Verification
main).cargo test --profile ci --locked -p cello --no-fail-fast: 878 passed, 0 failed (1 ignored).cargo clippy --profile ci --locked --all-targets -- -D warnings,cargo fmt --check,node scripts/check-docs.mjs: clean.Not changed, noted for the record:
getWriter()on a locked stream still uses Cello's message rather than workerd's "currently locked to a writer", and workerd answers the abort reason where Cello keeps the cancel reason on the cancel-then-abort repro; both are pre-existing and outside these issues.