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
3 changes: 1 addition & 2 deletions packages/cli-v3/src/dev/devSession.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ResolvedConfig } from "@trigger.dev/core/v3/build";
import * as esbuild from "esbuild";
import { existsSync, mkdirSync, rmSync } from "node:fs";
import { CliApiClient } from "../apiClient.js";
import {
BundleResult,
Expand Down Expand Up @@ -59,7 +58,7 @@ export async function startDevSession({
clearTmpDirs(rawConfig.workingDir);
const destination = getTmpDir(rawConfig.workingDir, "build", keepTmpFiles);
// Create shared store directory for deduplicating chunk files across rebuilds
const storeDir = getStoreDir(rawConfig.workingDir);
const storeDir = getStoreDir(rawConfig.workingDir, keepTmpFiles);

const runtime = await startWorkerRuntime({
name,
Expand Down
15 changes: 14 additions & 1 deletion packages/cli-v3/src/utilities/tempDirectories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,23 @@ export function clearTmpDirs(projectRoot: string | undefined) {
* Gets the shared store directory for content-addressable build outputs.
* This directory persists across rebuilds and is used to deduplicate
* identical chunk files between build versions.
* Automatically cleaned up when the process exits.
*/
export function getStoreDir(projectRoot: string | undefined): string {
export function getStoreDir(projectRoot: string | undefined, keep: boolean = false): string {
projectRoot ??= process.cwd();
const storeDir = path.join(projectRoot, ".trigger", "tmp", "store");
fs.mkdirSync(storeDir, { recursive: true });

// Register exit handler to clean up the store directory
if (!keep && !process.env.KEEP_TMP_DIRS) {
onExit(() => {
try {
fs.rmSync(storeDir, { recursive: true, force: true });
} catch (e) {
// This sometimes fails on Windows with EBUSY
}
});
}

return storeDir;
}