Skip to content

Commit e2bb043

Browse files
fix(release): accept large tarball entry lists (#111672)
1 parent cadad3b commit e2bb043

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

scripts/check-openclaw-package-tarball.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ function collectRequiredBundledWorkspaceDependencyErrors(
258258
}
259259

260260
const phaseTimingsEnabled = process.env.OPENCLAW_PACKAGE_TARBALL_CHECK_TIMINGS !== "0";
261+
// Self-contained artifacts can exceed Node's 1 MiB spawnSync output default.
262+
const TAR_LIST_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
261263
function runPhase(label, action) {
262264
const startedAt = performance.now();
263265
try {
@@ -273,11 +275,12 @@ function runPhase(label, action) {
273275
const list = runPhase("tar list", () =>
274276
spawnSync("tar", ["-tf", tarball], {
275277
encoding: "utf8",
278+
maxBuffer: TAR_LIST_MAX_BUFFER_BYTES,
276279
stdio: ["ignore", "pipe", "pipe"],
277280
}),
278281
);
279282
if (list.status !== 0) {
280-
fail(`tar -tf failed for ${tarball}: ${list.stderr || list.status}`);
283+
fail(`tar -tf failed for ${tarball}: ${list.stderr || list.error?.message || list.status}`);
281284
}
282285

283286
const extractDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-package-tarball-"));

test/scripts/check-openclaw-package-tarball.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { PACKAGE_INSTALL_GUARD_RELATIVE_PATH } from "../../scripts/lib/package-d
1717
import { WORKSPACE_TEMPLATE_PACK_PATHS } from "../../scripts/lib/workspace-bootstrap-smoke.mjs";
1818

1919
const CHECK_SCRIPT = "scripts/check-openclaw-package-tarball.mjs";
20+
const NODE_DEFAULT_SPAWN_MAX_BUFFER_BYTES = 1024 * 1024;
2021
const FLAT_PLUGIN_SDK_DECLARATION = "dist/plugin-sdk/provider-entry.d.ts";
2122
const DEEP_PLUGIN_SDK_DECLARATION = "dist/plugin-sdk/src/plugin-sdk/provider-entry.d.ts";
2223
const AI_RUNTIME_PACKAGE_JSON = JSON.stringify({
@@ -140,6 +141,36 @@ describe("check-openclaw-package-tarball", () => {
140141
expect(extra.stderr).not.toContain("OpenClaw package tarball does not exist");
141142
});
142143

144+
it("accepts tarballs whose entry list exceeds Node's default spawn buffer", () => {
145+
const longNameSuffix = "x".repeat(80);
146+
const largeEntryList = Object.fromEntries(
147+
Array.from({ length: 8_000 }, (_, index) => [
148+
`dist/control-ui/assets/large-entry-list/asset-${String(index).padStart(5, "0")}-${longNameSuffix}.txt`,
149+
"",
150+
]),
151+
);
152+
153+
withTarball(
154+
["dist/index.js"],
155+
{ "dist/index.js": "export {};\n", ...largeEntryList },
156+
(tarball) => {
157+
const listing = spawnSync("tar", ["-tf", tarball], {
158+
encoding: "utf8",
159+
maxBuffer: NODE_DEFAULT_SPAWN_MAX_BUFFER_BYTES * 2,
160+
});
161+
expect(listing.status, listing.stderr).toBe(0);
162+
expect(Buffer.byteLength(listing.stdout)).toBeGreaterThan(
163+
NODE_DEFAULT_SPAWN_MAX_BUFFER_BYTES,
164+
);
165+
166+
const result = spawnSync("node", [CHECK_SCRIPT, tarball], { encoding: "utf8" });
167+
168+
expect(result.status, result.stderr).toBe(0);
169+
expect(result.stdout).toContain("OpenClaw package tarball integrity passed.");
170+
},
171+
);
172+
});
173+
143174
it.runIf(process.platform !== "win32")(
144175
"removes the extract dir when tar extraction fails",
145176
() => {

0 commit comments

Comments
 (0)