Repository navigation
⚡ Bolt: bound /api/sw-probe maps to cap unbounded memory growth - #10633
Conversation
Fixes #10539. recordSwProbe stored every distinct client-supplied string forever; each map is now capped at 64 keys / 512 chars per key (same shape as the #4981 class-key cap), with counts for tracked keys still incrementing. 10k distinct keys -> 64 stored per map; GET payload 30KB bounded vs ~4.7MB and growing.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Fixes #10539. Part of scheduled Bolt run #10628.
💡 What:
recordSwProbe(pm-stack/aggregator/src/push.ts) stored every distinct client-supplied string from POST /api/sw-probe forever in two module-level maps. AddedMAX_SW_PROBE_KEYS = 64andMAX_SW_PROBE_KEY_LENGTH = 512caps (same shape as the #4981 class-key cap inalerts.ts): over-limit keys are dropped, counts for already-tracked keys still increment. Also skips__proto__keys, which could never be counted on a plain object. Regression tests intest/alerts.test.ts.🎯 Why: Request bodies are capped at 100KB, but distinct keys accumulate across requests — long-lived aggregator process grows memory and the GET summary payload without limit on an unauthenticated endpoint.
📊 Impact: Simulated 10k distinct URLs (100/request): stored keys capped at 64 per map (128 total); GET JSON payload 30KB bounded vs ~4.7MB and growing under the old code; record path stays O(1) amortized (one
Object.keysscan only on new-key insert, N≤64).🔬 Measurement:
bun /tmp/swprobe-bench.ts-style flood script againstrecordSwProbe/swProbeSummary; new tests assert count cap, length cap, increment-after-cap, payload <100KB, and no prototype pollution.bun test test/alerts.test.ts test/push-config-3729.test.ts: 55 pass.bunx tsc --noEmit: clean.bunx biome check src/push.ts: clean (test/alerts.test.tsorganize-imports finding is pre-existing on main, verified via stash). Fullbun test: 17 failures, all pre-existing network-dependent live-source tests — reproduced on the pristine tree with my changes reverted.Not merging: leaving open for human review per house rules (low-risk, but a second pair of eyes on cap values is welcome).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.