@@ -3,7 +3,7 @@ import { InputFile } from "node-appwrite/file";
33import { create as createTarball } from "tar" ;
44import { join , relative } from "node:path" ;
55import fs from "node:fs" ;
6- import { platform } from "node:os" ;
6+ import { platform , tmpdir } from "node:os" ;
77import { type AppwriteFunction , type Specification } from "appwrite-utils" ;
88import chalk from "chalk" ;
99import 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