Skip to content

Commit e509f85

Browse files
committed
[release] Write deploy tarball to tmpdir to avoid self-include during walk
1 parent c638058 commit e509f85

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/appwrite-utils-cli/src/functions/deployments.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { InputFile } from "node-appwrite/file";
33
import { create as createTarball } from "tar";
44
import { join, relative } from "node:path";
55
import fs from "node:fs";
6-
import { platform } from "node:os";
6+
import { platform, tmpdir } from "node:os";
77
import { type AppwriteFunction, type Specification } from "appwrite-utils";
88
import chalk from "chalk";
99
import cliProgress from "cli-progress";
@@ -81,7 +81,14 @@ export const uploadFunctionDeployment = async (
8181
MessageFormatter.processing("Preparing function deployment...", { prefix: "Deployment" });
8282

8383
const ignoredLower = ignored.map((pattern) => pattern.toLowerCase());
84-
const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
84+
// Write the tarball into the OS temp dir, not the cwd we are tarring.
85+
// Otherwise tar's recursive walk visits the output file while it is still
86+
// being written, the size grows mid-read, and node-tar throws
87+
// "did not encounter expected EOF" (write-entry.js:382). The function's
88+
// own `ignore` list typically doesn't list `function-*.tar.gz` because it
89+
// is implementation detail of this CLI, so the only safe fix is to move
90+
// the output entirely out of the walked tree.
91+
const tarPath = join(tmpdir(), `function-${functionId}-${Date.now()}.tar.gz`);
8592

8693
if (!fs.existsSync(codePath)) {
8794
throw new Error(`Function directory not found at ${codePath}`);

0 commit comments

Comments
 (0)