Repository navigation
fix: keep large package publishes under the publish action memory limit - #4944
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Codex review: needs maintainer review before merge. What this changesThis PR reduces ClawPack parsing allocations by reusing an inflation buffer, increasing compressed input chunks, and returning file-byte views. Example: Publish the 5.3 MB @openclaw/diffs beta.2 archive containing 24 MiB across 126 files.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main retains the implicated allocation pattern, and this maintainer-authored repair has clear value. No blocking code findings were identified. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared synchronous parser turns npm-pack archives into validated file entries for CLI operations and backend publication; the backend hashes the archive and stores each extracted file. flowchart TD
A[Publisher CLI] --> B[Authenticated publish endpoint]
B --> C[Staged archive in storage]
C --> D[Node preparation action]
D --> E[Shared bounded archive parser]
E --> F[Extracted file storage]
F --> G[Publication checks]
Technical reviewBest possible solution: Keep the focused allocation repair in the existing shared parser while preserving archive limits, exact file bytes, and synchronous CLI behavior. Do we have a high-confidence way to reproduce the issue? The allocation-heavy path and its production caller are source-verifiable, and the author reports exact-artifact failure and repeated memory measurements; the runtime-specific OOM was not independently reproduced in this read-only review. Is this the best way to solve the issue? This is an acceptable focused repair at the shared owner: it removes redundant copies without changing validation or callers; native asynchronous decompression would require a broader contract change whose runtime support is unverified. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 252a3f86d053. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 23, 2026, 5:36 PM ET / 22:36 UTC. |
Problem
Publishing
@openclaw/diffs(a 5.3 MB tarball that unpacks to 24 MiB across 126 files, including an 11.5 MB JS bundle) fails in production:absent.252a3f86returnedNode.js action execution ran out of memory (maximum memory usage: 512 MB)frompackageClawpackNode.prepareClawPackInternal.The same package published fine for beta.1 on Nov 19. Measuring the Nov 19 production commit shows the same peak, so this isn't a regression: diffs has been sitting at the limit, and beta.1 got through by luck.
The cause is
gunzipBoundedinpackages/clawhub/src/clawpack.ts. It pushes the archive into fflate's streamingGunzip1 KiB at a time, copies every output chunk, then concatenates them. Tar entries are then copied out again. The thousands of short-lived typed arrays inflate process RSS far beyond the data size. The JS heap stays under 50 MB, so this is native allocator churn, not retained data.Solution
ISIZEtrailer. The trailer is treated only as a hint, capped at the byte limit, and the buffer grows if the hint understates the size. The existing limit check stays authoritative.bytesToArrayBuffer,sha256Hex).Evidence
Peak RSS of
prepareClawPackInternalfor the real diffs beta.2 artifact (sha2567dd5dfae…), run under Node 24 with a mocked storage context:Parsing alone grows RSS by 537–624 MB on main and about 185 MB with this PR.
Tests:
ISIZEtrailer still inflates the full archive, and the byte limit is still enforced when the trailer lies.convex/lib/clawpack.test.ts(15), CLIpackages.test.ts,httpApiV1.handlers, and the template inventory runtime suites.tsc(root and CLI), oxlint and oxfmt are clean.Not measured: Convex's own Lambda baseline. This PR cuts peak RSS by about 300 MB, which should give diffs-sized packages ample headroom.
Follow-up option: native
DecompressionStreaminflates the same archive in about 40 MB. It would make the shared parser async, though, which touches three synchronous CLI call sites, and it depends on support in Convex's V8 runtime, which wasn't verified here.