http.compressionThreshold: docs say default 1200, shipped config sets 0 (compression off by default)
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
首先检查所引用的四个文档位置,并与 Harper 的 static/defaultConfig.yaml 负责人确认 compressionThreshold: 0 是否是有意为之。然后在统一更新所有文档值之前,验证 Harper 中对应的不一致以及 #655 的流问题;完成的标准是跨仓库决策已记录,并且四个页面与已发布的行为一致。
由索引模型根据 Issue 内容生成。
描述
What's wrong
The docs state that http.compressionThreshold defaults to 1200 bytes, so Brotli response compression is on out of the box. Harper's shipped configuration sets it to 0, and the runtime treats 0 as "off" — so on a default install, Brotli response compression never happens.
The root cause is not in this repo. Harper contradicts itself, and our docs faithfully mirror the half of it that isn't what actually ships.
Evidence (harper origin/main)
| Location | Says |
|---|---|
config-root.schema.json:25-31 |
property description: "Responses larger than this threshold (bytes) will be compressed... Default: 1200" |
config-root.schema.json:774 |
examples block: "compressionThreshold": 1200 |
static/defaultConfig.yaml:4 |
compressionThreshold: 0 — this is what gets written into a new install's config |
validation/configValidator.ts:329 |
compressionThreshold: number.optional() — no default injected |
server/serverHelpers/contentTypes.ts:362 |
const COMPRESSION_THRESHOLD = envMgr.get(CONFIG_PARAMS.HTTP_COMPRESSIONTHRESHOLD) — no || fallback, so a configured 0 stays 0 |
server/serverHelpers/contentTypes.ts:373 |
canCompress = COMPRESSION_THRESHOLD && request.headers...includes('br') — 0 is falsy, so compression is skipped entirely |
So the schema documents 1200, the shipped template sets 0, and the runtime honors 0. There is no code-level 1200 default anywhere.
Note this is specifically http.compressionThreshold. The unrelated storage.compressionThreshold (LMDB record compression) does have a real code default — (storage.pageSize || 4096) - 60 at resources/databases.ts:102 — which makes this easy to conflate when grepping.
Affected pages in this repo
reference/configuration/options.md:37- "Default:1200(bytes)"reference/http/configuration.md:111- thehttp.compressionThresholdsection, plus1200in examples at:123and:318reference/http/overview.md:104- "Compression applies when the response body exceeds the configuredcompressionThreshold(default 1200 bytes)"reference/configuration/operations.md:106-"compressionThreshold": 1200in a config response example
The question that has to be answered first
Is compressionThreshold: 0 in the shipped config intentional? The docs fix depends entirely on the answer, and the two outcomes are very different:
- If 0 is a bug in harper - Brotli compression has been silently off for every default install. That is the real finding here, and the fix belongs in
static/defaultConfig.yaml. Our docs then need no change beyond possibly noting the versions affected. - If 0 is intentional - then harper's own schema description and examples are wrong too, and our four locations should say compression is disabled by default and must be explicitly enabled. In that case
config-root.schema.jsonshould be corrected alongside.
Either way one of the two harper locations is wrong, so this likely wants a companion harper issue; transferring or cross-linking is fine.
Why it matters beyond a wrong number
Two things downstream depend on this:
- Anyone following our docs believes responses over 1200 bytes are compressed. If they are not, that is a real and invisible performance difference on a default install.
- There is a latent crash gated behind this setting.
contentTypes.ts:410-425pipesserializeStream's return value intocreateBrotliCompress()whenevercanCompressis true, but theapplication/x-msgpackhandler returns aBuffer(not a stream) for a plain array.Accept: application/x-msgpack+Accept-Encoding: br+ an array body would throwTypeError: stream.pipe is not a function. That is currently unreachable only because compression ships disabled - so if the default is "corrected" to 1200 without fixing the pipe path first, this becomes reachable the same day. Sequencing matters. Surfaced in #655.
Suggested fix
- Get a ruling from whoever owns
static/defaultConfig.yamlon whether 0 is intended. - Fix harper's inconsistency (either the shipped default or the schema description + examples).
- Update the four locations above to match, in one pass so they cannot disagree with each other.
- Track the
.pipe()normalization separately, and land it before any change that turns compression on by default.
sent with Claude Opus 5
- 主要语言
- MDX
- 星标
- 9
- 派生
- 9
- 平均合并
- 2 天 23 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
HarperFast/documentation 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
HarperFast/documentation#690 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
HarperFast/documentation#677 ·
维护者通常 2 天内回复
-
难度 2/5 半天 新手友好度 88/100
HarperFast/documentation#675 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
HarperFast/documentation#665 ·
维护者通常 2 天内回复
-
content
难度 2/5 1-3 小时 新手友好度 74/100
HarperFast/documentation#478 ·
维护者通常 2 天内回复
查看 HarperFast/documentation 的全部 Issue
相似的 Issue
-
customer-reported question
难度 2/5 1-3 小时 新手友好度 62/100
Azure/azure-sdk-for-python#49548 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Add the Yahoo chart API duplicate last-day row (yfinance#573) to incidents.md (about 1 hour)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭data docs good first issue
难度 1/5 1 小时以内 新手友好度 80/100
pacocartones/market-data-sanity-checker#160 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
nodejs/node#66743 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
Add a Storybook section to CONTRIBUTING.md可能已有人在做 @ChanakyaG2004 今天认领。 未关闭documentation good first issue
难度 2/5 1-3 小时 新手友好度 82/100
FlowwStar/FlowStar#995 · 2 条评论 ·
维护者通常 1 天内回复