Repository navigation
fix: TransformStream close after cancel rejects with the cancel reason (#129) - #135
Conversation
A readable cancel errors a TransformStream's writable with the cancel reason; writer.closed already reported it, but writer.close() took the errored early path and rejected with a generic TypeError. Close now rejects with the stream's stored error, as workerd does (the WHATWG text says a fresh TypeError). The same path covers WritableStream.prototype.close(), IdentityTransformStream and FixedLengthStream writes. The differential gate gains transform-close-after-cancel, and the TransformStream conformance fixture checks the close and closed reasons. Closes #129
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What
After
reader.cancel("bye")on aTransformStream's readable,writer.close()rejected withTypeError: Stream already closed/erroredinstead of the cancel reason thatwriter.closedalready reported. Workerd rejects with the stored error.Root cause:
WritableStream._closetreatederroredlikeclosedand returned a freshTypeError. It now rejects withstream._storedError, matching workerd;closedkeeps itsTypeError. The same path servesWritableStream.prototype.close()and theIdentityTransformStream/FixedLengthStreamwriters, whose readable cancel already errors the writable with workerd's convertedError.The WHATWG text says a fresh
TypeErrorfor an errored stream, so this is recorded as the third deliberate workerd deviation inwritable_stream.js.Fail-before
Gate case
transform-close-after-cancel, pre-fix binary:After the fix the case is
okand the full gate is 36/36 agreeing.Tests
node scripts/workerd-diff/runner.mjs— all 36 cases agree.cargo test --profile ci --locked— green (one unrelated flake ind1_concurrency_conformanceon one run, filed as test flake: tee-skew conformance can EPIPE its 40 MiB upload when the forwarded branch loses the skew budget #134; the re-run and the focused runs pass).transform_backpressure_conformance(new check 15: close and closed reasons after cancel),js_tee_budget_conformance,response_stream_budget_conformance,virtual_clock_conformance— green.cargo clippy --profile ci --all-targets --locked -- -D warnings,cargo fmt --check— clean.npm run validate,npm run build— clean.Out of scope, filed
writer.abort()on an errored writable rejects with the stored error where workerd resolves (sibling path, different direction, not shared root cause).writer.close()on a closed writable reports a differentTypeErrormessage than workerd.Closes #129
Summary by CodeRabbit
TypeError.TypeError.