diff --git a/.changeset/dev-session-store-dir.md b/.changeset/dev-session-store-dir.md new file mode 100644 index 00000000000..81dbf444c2d --- /dev/null +++ b/.changeset/dev-session-store-dir.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +Ensure the shared content-addressable store directory exists before writing so a second `trigger dev` session cannot crash after the previous session cleans it up. diff --git a/packages/cli-v3/src/utilities/fileSystem.ts b/packages/cli-v3/src/utilities/fileSystem.ts index d8632d96a75..ef8f6e07aa0 100644 --- a/packages/cli-v3/src/utilities/fileSystem.ts +++ b/packages/cli-v3/src/utilities/fileSystem.ts @@ -55,6 +55,10 @@ export async function createFileWithStore( await fsModule.unlink(filePath); } + // Ensure store directory exists. Concurrent `trigger dev` sessions share this + // path; the previous session's exit cleanup can delete it mid-build. + await fsModule.mkdir(storeDir, { recursive: true }); + // Check if content already exists in store by hash if (fsSync.existsSync(storePath)) { // Create hardlink from build path to store path