Skip to content

fix: keep large package publishes under the publish action memory limit - #4944

Merged
RomneyDa merged 1 commit into
mainfrom
fix/clawpack-publish-memory
Nov 23, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/clawpack-publish-memory

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

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:

  • OpenClaw 2026.11.10-beta.2 CI (run 45167770518): the trusted publish request got no response and timed out after 300 s with 0 bytes received. No receipt came back, and ClawHub still reports the version as absent.
  • A manual retry of the same sealed artifact against production at 252a3f86 returned Node.js action execution ran out of memory (maximum memory usage: 512 MB) from packageClawpackNode.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 gunzipBounded in packages/clawhub/src/clawpack.ts. It pushes the archive into fflate's streaming Gunzip 1 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

  • Inflate into one output buffer sized from the gzip ISIZE trailer. 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.
  • Raise the gzip input chunk from 1 KiB to 16 KiB. One push can still inflate to at most about 16 MiB before the limit check runs, so zip-bomb exposure stays bounded.
  • Return tar entries as views into the inflated buffer instead of copies. Every consumer already copies bytes before storing or hashing them (bytesToArrayBuffer, sha256Hex).

Evidence

Peak RSS of prepareClawPackInternal for the real diffs beta.2 artifact (sha256 7dd5dfae…), run under Node 24 with a mocked storage context:

Run 1 Run 2
main 756 MB 736 MB
this PR 445 MB 446 MB

Parsing alone grows RSS by 537–624 MB on main and about 185 MB with this PR.

Tests:

  • New: an understated ISIZE trailer still inflates the full archive, and the byte limit is still enforced when the trailer lies.
  • All pass: convex/lib/clawpack.test.ts (15), CLI packages.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 DecompressionStream inflates 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.

@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clawhub Ready Ready Preview Nov 23, 2026 10:28pm UTC

Request Review

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Production reportedly exhausts the Node action’s 512 MB limit; the mocked-storage measurements report 736–756 MB peak RSS.
  • After: The same mocked-storage measurements report 445–446 MB peak RSS; successful publication through real Convex remains unverified.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source review found no blocking defect, but mocked-storage measurements do not prove successful publication within the actual action limit.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A valid large plugin archive uploads but publication fails before a receipt or version is created.
Reason: The maintainer-authored direction addresses a concrete production failure with a small change to the existing shared parser.

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
Reviewed head: 64aa8ca2be860d8e723f94c043e90761c208130b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted terminal output or logs showing the same identified diffs artifact reaching successful preparation through the staged publish endpoint on real Convex with the candidate code; the added size-hint tests do not reproduce the memory failure.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Bounded streaming inflation and copied archive entries changes intended behavior with a stated reason (85a3fde: Added bounded archive validation and hierarchy safety; this PR explains replacing allocation mechanics while retaining those checks.)
  • Caller-specific tar budgets and typed limit errors keeps the original intent (c0f8c48: Supported bounded verified Template inventories and oversized-release handling; this PR preserves the authoritative budget and error type.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 0774d0f adds packages/clawhub/src/clawpack.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0774d0fe92ea; files: packages/clawhub/src/clawpack.ts)
  • Gio Della-Libera: Raw commit 85a3fde adds packages/clawhub/src/clawpack.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 85a3fde60834; files: packages/clawhub/src/clawpack.ts)
  • Patrick Erichsen: Raw commit c0f8c48 adds packages/clawhub/src/clawpack.ts:70 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c0f8c483a72f; files: packages/clawhub/src/clawpack.ts)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: The report identifies a current production memory failure blocking an official plugin release publish.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The report identifies a current production memory failure blocking an official plugin release publish.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 23, 2026, 5:36 PM ET / 22:36 UTC.

@RomneyDa
RomneyDa merged commit 424a90f into main Nov 23, 2026
78 of 81 checks passed
@RomneyDa
RomneyDa deleted the fix/clawpack-publish-memory branch November 23, 2026 23:16

This branch was successfully deployed

1 active deployment
Preview – clawhub — 64aa8ca2 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant