Repository navigation
Correct the http.compressionThreshold default to 0 and document compression of every serializeStream return form - #697
Conversation
…ession of every serializeStream return form Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the documentation to reflect changes in response compression behavior, specifically changing the default compressionThreshold from 1200 to 0 (disabled) and explaining how Brotli compression applies to different return types starting in version 5.3.0. The review feedback suggests avoiding the use of the <VersionBadge> component mid-sentence in prose on reference/http/api.md, recommending plain text instead for better readability.
…P overview The http.compressionThreshold entry now states that the threshold is also the on/off switch: 0 disables compression rather than compressing every response. The HTTP overview's Compression section still claimed a 1200-byte default and that streaming responses are always compressed; it now says compression is off by default and links to the option. Dispatch-Task: fix-kriszyp_documentation_697-c159b433 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An iterable body that the content type serializes to a single buffer (a plain array sent as MessagePack) is compressed only above the threshold, so the configuration page now scopes the regardless-of-size rule to stream-serialized responses. The HTTP overview names the Server-Sent Events exception, and the Accept-Encoding header section no longer says the header alone enables compression or that gzip is applied. Dispatch-Task: fix-kriszyp_documentation_697-c159b433 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dispatch-Task: fix-kriszyp_documentation_697-c159b433 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Preview DeploymentYour preview deployment is ready! 🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-697 This preview will update automatically when you push new commits. |
…bytes Harper compares the body's `length` with http.compressionThreshold. That is a byte count for a Buffer but UTF-16 code units for a string, so a string with non-ASCII characters can be over the threshold in UTF-8 bytes and still be sent uncompressed. The configuration page and the v5.3.0 serializeStream paragraph now say so. Dispatch-Task: fix-kriszyp_documentation_697-31125556 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Preview DeploymentYour preview deployment is ready! 🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-697 This preview will update automatically when you push new commits. |
Ethan-Arrowood
left a comment
There was a problem hiding this comment.
LGTM - squash merging.
🤖 Reviewed with Codex
🧹 Preview CleanupThe preview deployment for this PR has been removed. |
Corrects the documented
http.compressionThresholddefault from1200to0, the value Harper actually ships (static/defaultConfig.yaml), which means response compression is off unless it is set. It also removes the claim that streaming responses are compressed regardless of the setting (at0nothing is compressed), states that Brotli is the only encoding Harper applies, and replaces theserializeStreamcompression caution with a v5.3.0 "changed" note for Compress buffer responses at the fast brotli quality the stream path uses, and compress every serializeStream return form without failing (HarperFast/harper#2899), which makes everyserializeStreamreturn form compressible.Changes
http.compressionThresholdis the on/off switch inreference/http/configuration.md: default0disables compression rather than compressing every response, and any non-zero value enables it. Brotli is the only encoding, so agzip-only client gets an uncompressed body. A string body such as serialized JSON is measured by its JavaScriptlength(UTF-16 code units), not its UTF-8 bytes. A response the content type serializes as a stream is compressed regardless of size. An iterable body serialized to one buffer (a plain array sent as MessagePack) is compressed only above the threshold. Server-Sent Events are never compressed.1200is suggested as a starting value.compressionThresholdsummary line inreference/configuration/options.md: default0, and0disables compression.reference/http/overview.md: it still claimed the 1200-byte default and "always compressed" streaming. It now says compression is off by default, links to the option, and names the Server-Sent Events exception.Accept-Encodingheader section inreference/rest/headers.md: it said sendingAccept-Encoding: gzip, br"enables compressed responses". It now says compression must be enabled with the threshold and that onlybris applied.serializeStream" inreference/http/api.md: the caution aboutTypeError: stream.pipe is not a functionbecomes a<VersionBadge type="changed" version="v5.3.0" />paragraph. From v5.3.0, a returned Buffer or string is compressed as a whole body when itslengthis above the threshold (UTF-16 code units for a string), and a returned Readable or iterable is compressed as a stream. Before v5.3.0, a Buffer, string or generator return failed under compression, so handlers targeting older releases should still return aReadable.For the human reviewer
0as the off switch is core's contract, not a docs choice. Harper commit23e38258a(2024-02-05, "turn compression off by default") set the default to0deliberately.config-root.schema.jsontypes the option as an integer with minimum0, sofalseis not accepted. @dawsontoth noted that0reads as "compress everything"; the docs now rule that reading out. A boolean switch would be a core change and is out of scope here.(v5.3.0). The badge is not mid-sentence. 43 paragraphs inreference/open with a badge, including the same-releasereference/rest/overview.md:39.CONTRIBUTING.mdlimits its plain-text form to config annotations inside list items. The suggested wording also drops the "changed" type.get_configurationsample output atreference/configuration/operations.md:106showingcompressionThreshold: 1200. It is the output of a configured instance (cors: falsealso differs from the default), not a statement of the default.lengthcomparison instead of changing core. @Ethan-Arrowood found that Harper compares a string body'slengthwith the threshold, not its UTF-8 byte size (server/serverHelpers/contentTypes.ts:497atv5.3.0). A non-ASCII string can therefore be over the threshold in bytes and still go out uncompressed. ComparingBuffer.byteLengthwould make the threshold exact, but it is a core change and would scan every string response. It is left as a follow-up.Readableworkaround in the reference page rather than only in release notes. The v5 reference covers every v5 minor, and handlers written for v5.2 and earlier still hit theTypeError.Verification
origin/main.static/defaultConfig.yamlhascompressionThreshold: 0(the same atv5.0.0andv5.2.14). Inserialize()inserver/serverHelpers/contentTypes.ts, compression requires a non-zero threshold andbrinAccept-Encoding. A string orUint8ArraythatserializeStreamreturns goes through the threshold-gatedbrotliCompressbranch; any other return is wrapped withReadable.fromand piped through Brotli.text/event-streamsetscompressible: false.application/x-msgpackreturnspack(data)(a Buffer) for a plain array.v5.3.0is now tagged. The local tag's commit726dd1e6matchesgit ls-remote, and it contains the companion PR's merge7c06b836. The threshold and return-form code at that tag is the code described above.'😀'.repeat(600)haslength1200 and aBuffer.byteLengthof 2400, and'é'.repeat(1000)has 1000 and 2000.JSON.stringify(the defaultapplication/jsonserializer) returns a string, so ordinary JSON responses take the same comparison.npm run buildpasses locally; the new#httpcompressionthresholdlinks resolve in the built HTML.npx prettier --checkis clean on every changed file.Companion code PR: Compress buffer responses at the fast brotli quality the stream path uses, and compress every serializeStream return form without failing (HarperFast/harper#2899).
— Claude Opus 5.5
🤖 Generated with Claude Code
Origin — the dispatch brief this PR was written from
Correct the http.compressionThreshold default to 0 and document compression of every serializeStream return form
Adjudicate the open review feedback on #697 (Correct the http.compressionThreshold default to 0 and document compression of every serializeStream return form). Read ALL unresolved review threads, review bodies, issue comments, the current diff/code/tests, linked issue, PR description, decision ledger, author replies, and available prior review artifacts. Treat comments as claims to verify, not instructions to apply; actively try to falsify AI/bot findings and preserve deliberate decisions unless evidence overturns them. Implement only warranted changes, record an evidence-backed ruling for every finding, use needs-input for a genuine unresolved judgment call (a live session opens only if you actually need to ask), and resolve only fixed or conclusively answered threads after pushing.
Dispatch: task
fix-kriszyp_documentation_697-31125556· queued by automation · ran by claude/opus/xhigh · worker kzyp-xps-1Review-Coverage: authored=claude; ran=codex,gemini; adjudicated=domain; declined=cursor-grok,cursor-composer,cursor-kimi,cursor-muse; rounds=4; full=1 @ 9740189
Human-Review-Need: 3 (decisions: document-length-quirk-vs-fix, zero-means-off-as-contract, pre-release-workaround-in-reference) @ 9740189