perf: skip unneeded passthrough request body buffers - #212
Closed
PekingSpades wants to merge 1 commit into
Closed
PekingSpades wants to merge 1 commit into
PekingSpades wants to merge 1 commit into
Conversation
Stream unobserved uploads directly while retaining replay buffers for recording, subscriptions, callbacks, transforms and earlier readers. Keep forwarding, trailers and cancellation intact for streamed bodies.
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.
Ordinary passthrough currently starts a replay buffer even when recording and all body consumers are disabled. Stream those uploads directly, and keep replay buffering for recording, subscriptions, callbacks, transforms and readers started by earlier matchers or steps.
Fixes #211.
Complete reproduction: #211. Based on v4.6.3 (
10e33d5).Changes
Actual before/after comparison
The report's loopback reproduction uploads 16 MiB with
recordTraffic: false, consumes it at the target, and holds the target response open while measuring.The two failing baseline regressions are the unobserved HTTP/1 and HTTP/2 uploads. The other nine compatibility cases pass on both versions. The byte counter measures the request reader's retained chunks, not whole-process memory.
Using the script from the report and a built checkout at
../mockttp:Validation
npm run build: passed.The remaining failures were existing live TLS passthrough cases:
skips the server for matching HTTPS requestsandbypasses Mockttp for TLS connections inside matching HTTP/1 CONNECT tunnel. Both also failed on the unmodified baseline (disconnect/timeout).All validation used Node 24.19.0, with freshly installed upstream dependencies. Browser checks used Chrome Headless 151.0.7922.34. The full Node suite used a local pkimetal service and a 30-second Mocha timeout. Existing live-network outcomes vary between runs; the deterministic regression and loopback comparisons isolate these changes.