Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,34 @@ describe("functions deploy", () => {
}).pipe(Effect.ensuring(cleanupTempDir(tempDir)));
});

it.live("fails with a contextual error when Docker bundling produces no eszip output", () => {
const tempDir = makeTempDir();
const child = mockChildProcessSpawner({ exitCode: 0 });

return Effect.gen(function* () {
yield* Effect.promise(() => writeProjectConfig(tempDir));
yield* Effect.promise(() => writeLocalFunction(tempDir, "hello-world"));

const { out, layer } = setup(tempDir, {
rawArgs: ["functions", "deploy", "hello-world", "--use-docker"],
childLayer: child.layer,
});

const error = yield* functionsDeploy({
...BASE_FLAGS,
functionNames: ["hello-world"],
useDocker: true,
}).pipe(Effect.provide(layer), Effect.flip);

expect(error).toBeInstanceOf(Error);
if (error instanceof Error) {
expect(error.message).toContain("failed to open eszip:");
expect(error.message).toContain("output.eszip");
}
expect(out.stderrText).toContain("Bundling Function: hello-world\n");
}).pipe(Effect.ensuring(cleanupTempDir(tempDir)));
});

it.live(
"accepts nullable optional fields when listing remote functions for Docker deploys",
() => {
Expand Down
8 changes: 7 additions & 1 deletion apps/cli/src/shared/functions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,13 @@ const bundleFunctionWithDocker = Effect.fnUntraced(function* (
return yield* Effect.fail(new Error(`failed to bundle function: exit ${result.exitCode}`));
}

const eszip = yield* Effect.tryPromise(() => readFile(outputPath));
const eszip = yield* Effect.tryPromise({
try: () => readFile(outputPath),
catch: (error) =>
new Error(
`failed to open eszip: ${error instanceof Error ? error.message : String(error)}`,
),
});
const compressed = new Uint8Array(
Buffer.concat([
Buffer.from(COMPRESSED_ESZIP_MAGIC),
Expand Down
Loading