Skip to content

Conversation

@ericallam
Copy link
Member

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

⚠️ No Changeset found

Latest commit: 249cdf7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

The changes update the temporary directory management system by adding an optional parameter to the getStoreDir function. The function now accepts a keep parameter to control whether temporary directories should be preserved. When keep is false and the KEEP_TMP_DIRS environment variable is not set, an exit handler automatically cleans up the store directory on process termination. The call site in devSession.ts is updated to pass this new parameter from the keepTmpFiles variable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Attention to cleanup logic: Verify that the onExit handler correctly removes the store directory and doesn't interfere with other cleanup operations
  • Verify that the default parameter value (false) aligns with the intended behavior and doesn't cause unexpected cleanup in existing code paths
  • Check that the KEEP_TMP_DIRS environment variable check works as expected

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is missing entirely; no content was provided by the author to explain the changes, testing, or reasoning. Add a comprehensive pull request description following the repository template, including issue reference, testing steps, and changelog entry.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding automatic cleanup of the store directory on dev CLI exit, which is the primary objective of this changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ea-branch-106

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/cli-v3/src/utilities/tempDirectories.ts (1)

68-82: Consider guarding against multiple exit handler registrations.

Each call to getStoreDir registers a new exit handler. If the function is called multiple times (e.g., across multiple dev sessions in the same process), multiple handlers will be registered for the same directory. While fs.rmSync with force: true is idempotent and the current usage pattern calls this once per session, you could add a guard to prevent duplicate registrations.

Optional enhancement using a module-level flag:

+let storeExitHandlerRegistered = false;
+
 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) {
+  if (!keep && !process.env.KEEP_TMP_DIRS && !storeExitHandlerRegistered) {
+    storeExitHandlerRegistered = true;
     onExit(() => {
       try {
         fs.rmSync(storeDir, { recursive: true, force: true });
       } catch (e) {
         // This sometimes fails on Windows with EBUSY
       }
     });
   }

   return storeDir;
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 748ae65 and 2337528.

📒 Files selected for processing (3)
  • .changeset/strange-beds-poke.md (1 hunks)
  • packages/cli-v3/src/dev/devSession.ts (1 hunks)
  • packages/cli-v3/src/utilities/tempDirectories.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead

Files:

  • packages/cli-v3/src/dev/devSession.ts
  • packages/cli-v3/src/utilities/tempDirectories.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function declarations instead of default exports

Files:

  • packages/cli-v3/src/dev/devSession.ts
  • packages/cli-v3/src/utilities/tempDirectories.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier

Files:

  • packages/cli-v3/src/dev/devSession.ts
  • packages/cli-v3/src/utilities/tempDirectories.ts
🧠 Learnings (11)
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Run `npx trigger.devlatest dev` to start the Trigger.dev development server

Applied to files:

  • .changeset/strange-beds-poke.md
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Run `npx trigger.devlatest init` to initialize a Trigger.dev project

Applied to files:

  • .changeset/strange-beds-poke.md
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Configure build process in trigger.config.ts using `build` object with external packages, extensions, and JSX settings

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Use build extensions in trigger.config.ts (additionalFiles, additionalPackages, aptGet, prismaExtension, etc.) to customize the build

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Configure Trigger.dev project in `trigger.config.ts` using `defineConfig()` with project ref and task directories

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `trigger.dev/sdk/v3` for all imports in Trigger.dev tasks

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use the `task()` function from `trigger.dev/sdk/v3` to define tasks with id and run properties

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, use subpath exports from the package.json instead of importing from the root path

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: The SDK at packages/trigger-sdk is an isomorphic TypeScript SDK

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use logger methods (debug, log, info, warn, error) from `trigger.dev/sdk/v3` for structured logging in tasks

Applied to files:

  • packages/cli-v3/src/dev/devSession.ts
🧬 Code graph analysis (1)
packages/cli-v3/src/dev/devSession.ts (1)
packages/cli-v3/src/utilities/tempDirectories.ts (1)
  • getStoreDir (68-85)
🪛 LanguageTool
.changeset/strange-beds-poke.md

[style] ~5-~5: Consider an alternative adverb to strengthen your wording.
Context: ...gger.dev": patch --- fix(dev): CLI now properly cleans up the store dir on dev CLI exit...

(PROPERLY_THOROUGHLY)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (22)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
.changeset/strange-beds-poke.md (1)

1-5: LGTM!

The changeset correctly documents the patch-level fix for store directory cleanup on dev CLI exit.

packages/cli-v3/src/dev/devSession.ts (1)

61-61: LGTM!

The keepTmpFiles parameter is correctly passed to getStoreDir, enabling control over temporary directory cleanup behavior.

packages/cli-v3/src/utilities/tempDirectories.ts (1)

66-66: LGTM!

The documentation correctly describes the new automatic cleanup behavior.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli-v3/src/utilities/tempDirectories.ts (1)

62-67: Doc comment should reflect that cleanup is conditional.

The comment states the store directory is "Automatically cleaned up when the process exits", but the implementation at line 74 shows cleanup only happens when both keep is false AND KEEP_TMP_DIRS is not set. Update the doc comment:

- * Automatically cleaned up when the process exits.
+ * Automatically cleaned up when the process exits, unless KEEP_TMP_DIRS is set
+ * or the caller passes `keep = true`.
🧹 Nitpick comments (2)
packages/cli-v3/src/utilities/tempDirectories.ts (2)

9-12: Prefer type alias over interface for EphemeralDirectory.

This is pre-existing, but TS guidelines here favor type aliases over interface. When you next touch this, consider:

-export interface EphemeralDirectory {
+export type EphemeralDirectory = {
   path: string;
   remove(): void;
-}
+};

73-82: Exit-handler registration is fine, but consider deduping and sharing safe rm logic.

Each getStoreDir call (with keep === false and no KEEP_TMP_DIRS) registers a new onExit handler, even if the store dir path is identical. This is safe but can add redundant listeners. Also, the “rmSync with EBUSY guard” logic is now duplicated in three places in this file.

If this path is hit often in a long-lived process, consider:

  • Tracking a Set<string> of store dirs to ensure you only register one handler per dir, and/or
  • Extracting a small safeRemoveDir(dir: string) helper reused by getTmpDir, clearTmpDirs, and this exit handler.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2337528 and 249cdf7.

📒 Files selected for processing (2)
  • packages/cli-v3/src/dev/devSession.ts (1 hunks)
  • packages/cli-v3/src/utilities/tempDirectories.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli-v3/src/dev/devSession.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead

Files:

  • packages/cli-v3/src/utilities/tempDirectories.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function declarations instead of default exports

Files:

  • packages/cli-v3/src/utilities/tempDirectories.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier

Files:

  • packages/cli-v3/src/utilities/tempDirectories.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: typecheck / typecheck
🔇 Additional comments (1)
packages/cli-v3/src/utilities/tempDirectories.ts (1)

68-68: Verify call sites to ensure the default parameter change doesn't break existing persistence requirements.

The prior behavior is unclear in the current repository context, so manual verification is needed. The suggestion to audit call sites with rg -n "getStoreDir\(" packages/cli-v3 remains valid. Specifically:

  1. Check each call site to determine if it explicitly passes keep=true or relies on the prior default behavior
  2. Verify that dev/test code paths handle the new auto-cleanup default correctly
  3. If any production code relies on persistence without explicitly passing keep=true, either update call sites or reconsider the default value

Consider keeping the default as keep=true for backward compatibility unless dev session cleanup is explicitly opt-in elsewhere.

@myftija myftija merged commit e7fec40 into main Dec 4, 2025
31 checks passed
@myftija myftija deleted the ea-branch-106 branch December 4, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants