fix: improve streaming and WebSocket WHATWG compatibility - #25
Merged
Conversation
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.
Summary
This PR rolls up all changes since
v3.0.0, with a focus on streaming request bodies, WHATWG compatibility, WebSocket lifecycle correctness, and native resource cleanup.Changes since v3.0.0
Request, Response, and streaming bodies
Blob,ReadableStream, async iterable, and iterable request bodies through the native transport with backpressure instead of buffering them in JSRequestbodies as streams instead of callingarrayBuffer()Request.body,bodyUsed, cloning, transfer, GET/HEAD body validation, URL parsing, credential rejection, and method normalization with Fetch behaviorContent-Typeheaders forFormDataRequest.blob()andResponse.blob()and addbytes()readersHeaderscompatibility with global headers, tuple validation,keys(),values(), andforEach()Requestas a named ESM export and add compile-time compatibility checks against the global Fetch typesWebSocket
new WebSocket(url, protocols)constructor form and converthttp:/https:URLs tows:/wss:close()is called duringCONNECTING, preventing a later spuriousopeneventsend()call timesend()behavior inCONNECTING,CLOSING, andCLOSEDstates and improvebufferedAmounttrackingMessageEvent.origin, use WHATWG-styleDOMExceptionerrors for protocol validation, and ignore invalidbinaryTypeassignmentserrorandcloseevent pathNative resource lifecycle
Tests and tooling
oxfmtfrom0.60to0.61New contributor
Special thanks to @chad-loder for identifying and fixing the failed response-body cleanup leak in #23. That fix prevents broken streamed responses from retaining a socket and exhausting the connection pool over time.
Validation
npm test— 116 tests passedcargo test --manifest-path rust/Cargo.toml— 6 tests passednpm run lintnpm run build:tsnpm run lint:rust