fix(request-executor): serialize every request option in toJSON - #770
Draft
aborovsky wants to merge 1 commit into
Draft
fix(request-executor): serialize every request option in toJSON#770aborovsky wants to merge 1 commit into
aborovsky wants to merge 1 commit into
Conversation
`Request.toJSON()` omitted `timeout`, `maxContentSize`, `decompress`, `keepAlive` and `encoding`, and `transformScript` rebuilds the request from it. Every script-transformed request therefore lost its per-request timeout and response size cap and silently fell back to the executor-level defaults, both of which the Bright server sets per request. `decompress` was worse than dropped: the constructor defaults it to `true`, so an explicit `false` was flipped. Serialize the full option set instead. The script payload still reports no `encoding`, because the body handed to the script is already decoded and claiming otherwise would describe it incorrectly.
aborovsky
force-pushed
the
fix/request-tojson-complete
branch
from
August 6, 2026 11:14
dee3c5f to
0a8b54e
Compare
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.
Follow-up to #769, addressing #769 (comment).
Problem
Request.toJSON()omittedtimeout,maxContentSize,decompress,keepAliveandencoding.transformScriptrebuilds the request from that projection, so every script-transformed request was reconstructed from a lossy copy.Round-tripping a request through
toJSON()before this change:timeout1234undefinedmaxContentSize99undefinedkeepAlivetrueundefineddecompressfalsetrueencoding'base64'undefined(fixed in #769)Impact, in order of severity:
timeoutandmaxContentSizeare reachable and were genuinely lost.RepeaterServerRequestEventcarries both from the Bright server andServerRepeaterLauncherspreads the event straight intonew Request({ ...event }). After a script transform they wereundefined, soapplyCurlTimeoutsilently fell back to the executor-leveltimeoutand the response cap fell back tomaxContentLength.decompresswas worse than dropped. The constructor defaults it totrue, so omitting it flipped an explicitfalse. Nothing in the codebase currently setsdecompress: false, so this was not reachable in practice.keepAliveis unread. Nothing consumesRequest.keepAlive; connection reuse is driven entirely by the executor-levelreuseConnection. Included for completeness only.Change
toJSON()now serializes the full option set the constructor accepts, sonew Request(request.toJSON())is a faithful copy.Because
toJSON()now carriesencoding, the script payload explicitly overrides it toundefined. The body handed to a script is already decoded, so reportingencoding: 'base64'next to it would describe it incorrectly and mislead any script that inspectsoptions.encoding. This keeps the decoded-view contract intact and leaves the restore logic added in #769 behaving exactly as it does today.Tests
Four new tests, each verified to fail without the source change:
toJSONround-trips every option the constructor acceptsdecompress: falsesurvives instead of defaulting back totruetimeoutis honoured after a script transform (without the fix the request is unbounded and the slow response arrives successfully)timeout/maxContentSize/decompressbut noencodingsrc/suite: 264 passed across 24 suites.src/RequestExecutor/: 98 passed (94 onnext+ 4 new). eslint clean.tsc --noEmitreports one error atHttpRequestExecutor.spec.ts:158; it is pre-existing onnextand untouched by this branch (the only hunk here starts at line 1495).E2E and smoke suites were not run — they require live Bright API credentials.