uws: fix O(n^2) BackPressure buffer compaction and reallocation on large writes - #34023
Open
robobun wants to merge 4 commits into
Open
uws: fix O(n^2) BackPressure buffer compaction and reallocation on large writes#34023robobun wants to merge 4 commits into
robobun wants to merge 4 commits into
Claude / Claude Code Review
completed
Jul 14, 2026 in 12m 35s
Code review found 1 important issue
Found 3 candidates, confirmed 1. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 1 |
| 🟡 Nit | 0 |
| 🟣 Pre-existing | 0 |
| Severity | File:Line | Issue |
|---|---|---|
| 🔴 Important | packages/bun-uws/src/HttpResponse.h:602-607 |
Recursive UINT_MAX split re-triggers reserve, doubling capacity beyond need |
Annotations
Check failure on line 607 in packages/bun-uws/src/HttpResponse.h
claude / Claude Code Review
Recursive UINT_MAX split re-triggers reserve, doubling capacity beyond need
The `UINT_MAX` split at line 619 recursively calls `this->write(...)`, so this reserve block fires again on each recursive chunk — and since it requests `max(cap*2, need)` without first checking whether `need` already fits, the inner call always doubles. For the PR's 4 GiB test case: outer call reserves ~4 GiB, then the recursive `write(UINT_MAX)` sees `cap*2 ≈ 8 GiB > need` and reserves 8 GiB (contradicting the review-thread claim that it 'reserves exactly once'); for k UINT_MAX chunks it doubl
Loading