-
-
Notifications
You must be signed in to change notification settings - Fork 926
feat(engine): run debounce system #2794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f048420 The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughIntroduces debounce support across the system: DB migration and Prisma schema add a JSONB Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
| if (taskRun.friendlyId !== runFriendlyId) { | ||
| event.stop(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Debounced triggers lose trace span
event.stop() runs whenever taskRun.friendlyId !== runFriendlyId, but the replacement span is only created via onDebounced (only set for debounce + resumeParentOnCompletion). For debounced non-triggerAndWait triggers, the outer span gets stopped and no debounced span is created, so the debounced trigger disappears from tracing.
internal-packages/run-engine/src/engine/systems/debounceSystem.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (8)
apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx (1)
559-571: Consider displaying debounce creation timestamp and formatting the delay consistently.The implementation correctly displays the debounce key and delay. However, based on the debounce payload structure (
{ key: string; delay: string; createdAt: Date }), thecreatedAttimestamp is available but not shown. Consider these optional enhancements:
- Display createdAt: Similar to how the Idempotency field shows expiration (lines 549-555), displaying when the debounce was created could provide useful context.
- Consistent duration formatting: If
delayrepresents a duration, consider usingformatDurationMilliseconds(already imported at line 9) for consistency with other duration displays in this file (e.g., line 731-733).Example enhancement:
<Property.Item> <Property.Label>Debounce</Property.Label> <Property.Value> {run.debounce ? ( <div> <div className="break-all">Key: {run.debounce.key}</div> <div>Delay: {run.debounce.delay}</div> + <div> + Created: <DateTime date={run.debounce.createdAt} /> + </div> </div> ) : ( "–" )} </Property.Value> </Property.Item>apps/webapp/app/env.server.ts (1)
614-618: Env schema for maximum debounce duration is consistentThe new
RUN_ENGINE_MAXIMUM_DEBOUNCE_DURATION_MSentry is typed and defaulted correctly (1 hour). If you never want to allow non‑positive values, consider adding.positive()to fail fast on bad configuration, but current behavior is acceptable if “0 disables / no cap” is intentional.packages/trigger-sdk/src/v3/shared.ts (1)
2035-2058: Single-run debounce wiring is correct; consider batch supportForwarding
options?.debounceintotriggerTaskhere correctly exposes debounce fortasks.trigger()and task instance.trigger().If you intend
debounceto work with batch APIs as well (e.g.tasks.batchTrigger,batch.trigger, etc.), you’ll likely want to mirror this by threadingdebouncethrough the various batch option mappers (e.g. per‑itemoptionsobjects inbatchTrigger_internaland thetransform*BatchItems*helpers) so those paths don’t silently ignore a provided debounce option.internal-packages/run-engine/src/engine/systems/delayedRunSystem.ts (1)
140-168: Consider atomic update with status check to prevent stale updates.The status update to
PENDINGat line 145 happens after the enqueue. In a rare race, if the run status changed between the snapshot check (line 107) and this update, the status could be incorrectly overwritten. Consider using a conditional update:const updatedRun = await this.$.prisma.taskRun.update({ - where: { id: runId }, + where: { + id: runId, + status: "DELAYED", + }, data: { status: "PENDING", queuedAt, }, });However, since the lock is held throughout the operation, this is likely safe in practice.
apps/webapp/app/presenters/v3/SpanPresenter.server.ts (1)
237-237: Consider using zod for JSON field validation.The
debouncefield is a JSON column cast directly. Per coding guidelines forapps/webapp, consider using zod for validation to ensure runtime type safety:import { z } from "zod"; const DebounceData = z.object({ key: z.string(), delay: z.string(), createdAt: z.coerce.date(), }).nullable(); // Then in getRun: debounce: DebounceData.parse(run.debounce),This provides runtime validation and better error messages if the data is malformed.
apps/webapp/app/runEngine/services/triggerTask.server.ts (1)
352-377: Consider adding error handling in theonDebouncedcallback.The
onDebouncedcallback creates a traced span but doesn't handle potential errors fromtraceDebouncedRun. If the tracing fails, the error would propagate and potentially break the debounce flow.onDebounced: body.options?.debounce && body.options?.resumeParentOnCompletion ? async ({ existingRun, waitpoint, debounceKey }) => { + try { return await this.traceEventConcern.traceDebouncedRun( triggerRequest, parentRun?.taskEventStore, { existingRun, debounceKey, incomplete: waitpoint.status === "PENDING", isError: waitpoint.outputIsError, }, async (spanEvent) => { const spanId = options?.parentAsLinkType === "replay" ? spanEvent.spanId : spanEvent.traceparent?.spanId ? `${spanEvent.traceparent.spanId}:${spanEvent.spanId}` : spanEvent.spanId; return spanId; } ); + } catch (error) { + logger.error("Failed to trace debounced run", { error, debounceKey }); + return undefined; + } } : undefined,This ensures tracing failures don't break the debounce functionality.
internal-packages/run-engine/src/engine/tests/debounce.test.ts (1)
1226-1242: Consider addingconcurrencyLimitBurstFactorfor consistency.The
devEnvironmentcreation is missingconcurrencyLimitBurstFactorwhich is included insetupAuthenticatedEnvironment. While this likely has a default value, adding it would ensure consistency between test environments.data: { type: "DEVELOPMENT", slug: "dev-slug", projectId: prodEnvironment.projectId, organizationId: prodEnvironment.organizationId, apiKey: "dev_api_key", pkApiKey: "dev_pk_api_key", shortcode: "dev_short", maximumConcurrencyLimit: 10, + concurrencyLimitBurstFactor: new Decimal(2.0), },Note: You'll need to import
Decimalfrom the appropriate package.internal-packages/run-engine/src/engine/systems/debounceSystem.ts (1)
178-179: Consider usingsetTimeoutfromtimers/promisesfor consistency.The current implementation uses a Promise wrapper around
setTimeout, butsetTimeoutfromtimers/promisesis already available and would be more idiomatic.+import { setTimeout } from "timers/promises"; + // In waitForExistingRun: -await new Promise((resolve) => setTimeout(resolve, CLAIM_RETRY_DELAY_MS)); +await setTimeout(CLAIM_RETRY_DELAY_MS);
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
references/hello-world/src/trigger/debounce.tsis excluded by!references/**
📒 Files selected for processing (25)
.cursor/rules/migrations.mdc(1 hunks)ai/references/migrations.md(1 hunks)apps/webapp/app/env.server.ts(1 hunks)apps/webapp/app/presenters/v3/SpanPresenter.server.ts(2 hunks)apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx(1 hunks)apps/webapp/app/runEngine/concerns/traceEvents.server.ts(2 hunks)apps/webapp/app/runEngine/services/triggerTask.server.ts(2 hunks)apps/webapp/app/runEngine/types.ts(2 hunks)apps/webapp/app/v3/runEngine.server.ts(1 hunks)apps/webapp/package.json(2 hunks)apps/webapp/test/engine/triggerTask.test.ts(2 hunks)docs/triggering.mdx(1 hunks)internal-packages/database/prisma/migrations/20251216225303_add_debounce_and_delayed_status/migration.sql(1 hunks)internal-packages/database/prisma/schema.prisma(2 hunks)internal-packages/run-engine/src/engine/index.ts(10 hunks)internal-packages/run-engine/src/engine/systems/debounceSystem.ts(1 hunks)internal-packages/run-engine/src/engine/systems/delayedRunSystem.ts(3 hunks)internal-packages/run-engine/src/engine/systems/waitpointSystem.ts(1 hunks)internal-packages/run-engine/src/engine/tests/debounce.test.ts(1 hunks)internal-packages/run-engine/src/engine/types.ts(3 hunks)packages/core/src/v3/schemas/api.ts(1 hunks)packages/core/src/v3/schemas/runEngine.ts(1 hunks)packages/core/src/v3/types/tasks.ts(1 hunks)packages/trigger-sdk/package.json(1 hunks)packages/trigger-sdk/src/v3/shared.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{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/core/src/v3/schemas/api.tsapps/webapp/app/v3/runEngine.server.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsxpackages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsapps/webapp/app/presenters/v3/SpanPresenter.server.tsinternal-packages/run-engine/src/engine/types.tspackages/core/src/v3/schemas/runEngine.tsapps/webapp/app/env.server.tsinternal-packages/run-engine/src/engine/systems/delayedRunSystem.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsinternal-packages/run-engine/src/engine/systems/waitpointSystem.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use zod for validation in packages/core and apps/webapp
Files:
packages/core/src/v3/schemas/api.tsapps/webapp/app/v3/runEngine.server.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsxpackages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsapps/webapp/app/presenters/v3/SpanPresenter.server.tspackages/core/src/v3/schemas/runEngine.tsapps/webapp/app/env.server.tsapps/webapp/app/runEngine/services/triggerTask.server.tsapps/webapp/test/engine/triggerTask.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Files:
packages/core/src/v3/schemas/api.tsapps/webapp/app/v3/runEngine.server.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsxpackages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsapps/webapp/app/presenters/v3/SpanPresenter.server.tsinternal-packages/run-engine/src/engine/types.tspackages/core/src/v3/schemas/runEngine.tsapps/webapp/app/env.server.tsinternal-packages/run-engine/src/engine/systems/delayedRunSystem.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsinternal-packages/run-engine/src/engine/systems/waitpointSystem.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier
Files:
packages/core/src/v3/schemas/api.tspackages/trigger-sdk/package.jsonapps/webapp/app/v3/runEngine.server.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsxpackages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsapps/webapp/app/presenters/v3/SpanPresenter.server.tsinternal-packages/run-engine/src/engine/types.tspackages/core/src/v3/schemas/runEngine.tsapps/webapp/app/env.server.tsapps/webapp/package.jsoninternal-packages/run-engine/src/engine/systems/delayedRunSystem.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsai/references/migrations.mdinternal-packages/run-engine/src/engine/systems/waitpointSystem.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.ts
apps/webapp/app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
Access all environment variables through the
envexport ofenv.server.tsinstead of directly accessingprocess.envin the Trigger.dev webapp
Files:
apps/webapp/app/v3/runEngine.server.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsxapps/webapp/app/runEngine/types.tsapps/webapp/app/presenters/v3/SpanPresenter.server.tsapps/webapp/app/env.server.tsapps/webapp/app/runEngine/services/triggerTask.server.tsapps/webapp/app/runEngine/concerns/traceEvents.server.ts
apps/webapp/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
apps/webapp/**/*.{ts,tsx}: When importing from@trigger.dev/corein the webapp, use subpath exports from the package.json instead of importing from the root path
Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp
Files:
apps/webapp/app/v3/runEngine.server.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsxapps/webapp/app/runEngine/types.tsapps/webapp/app/presenters/v3/SpanPresenter.server.tsapps/webapp/app/env.server.tsapps/webapp/app/runEngine/services/triggerTask.server.tsapps/webapp/test/engine/triggerTask.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.ts
**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use vitest for all tests in the Trigger.dev repository
Files:
apps/webapp/test/engine/triggerTask.test.tsinternal-packages/run-engine/src/engine/tests/debounce.test.ts
apps/webapp/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
Test files should only import classes and functions from
app/**/*.tsfiles and should not importenv.server.tsdirectly or indirectly; pass configuration through options instead
Files:
apps/webapp/test/engine/triggerTask.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.{ts,tsx,js,jsx}: Test files should live beside the files under test and use descriptivedescribeanditblocks
Avoid mocks or stubs in tests; use helpers from@internal/testcontainerswhen Redis or Postgres are needed
Use vitest for unit tests
Files:
apps/webapp/test/engine/triggerTask.test.tsinternal-packages/run-engine/src/engine/tests/debounce.test.ts
packages/trigger-sdk/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Files:
packages/trigger-sdk/src/v3/shared.ts
🧠 Learnings (52)
📚 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 `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation
Applied to files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/types.tsapps/webapp/app/runEngine/services/triggerTask.server.tspackages/trigger-sdk/src/v3/shared.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/core/src/v3/schemas/api.tspackages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tspackages/trigger-sdk/src/v3/shared.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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 `idempotencyKeyTTL` option to define a time window during which duplicate triggers return the original run
Applied to files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsapps/webapp/app/presenters/v3/SpanPresenter.server.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxinternal-packages/run-engine/src/engine/systems/debounceSystem.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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} : Limit task duration using the `maxDuration` property (in seconds)
Applied to files:
packages/core/src/v3/schemas/api.tsapps/webapp/app/v3/runEngine.server.tspackages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/types.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.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 `idempotencyKeys.create()` to create idempotency keys for preventing duplicate task executions
Applied to files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/types/tasks.tsdocs/triggering.mdxinternal-packages/run-engine/src/engine/tests/debounce.test.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/core/src/v3/schemas/api.tspackages/trigger-sdk/package.jsonpackages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/types.tspackages/trigger-sdk/src/v3/shared.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 metadata methods (set, del, replace, append, remove, increment, decrement, stream, flush) to update metadata during task execution
Applied to files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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} : Configure task retry behavior using the `retry` property with options like maxAttempts, factor, and timeout values
Applied to files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/types.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} : Attach metadata to task runs using the metadata option when triggering, and access/update it inside runs using metadata functions
Applied to files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxinternal-packages/run-engine/src/engine/systems/debounceSystem.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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} : Generate example payloads for tasks when possible
Applied to files:
packages/core/src/v3/schemas/api.tsdocs/triggering.mdx
📚 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/trigger-sdk/package.json
📚 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/trigger-sdk/package.json
📚 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/trigger-sdk/package.jsonapps/webapp/package.json
📚 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 : Set default maximum duration in trigger.config.ts using `maxDuration` property
Applied to files:
apps/webapp/app/v3/runEngine.server.tsapps/webapp/app/env.server.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: Use the Run Engine 2.0 from `internal/run-engine` for new run lifecycle code in the webapp instead of the legacy run engine
Applied to files:
apps/webapp/app/v3/runEngine.server.ts
📚 Learning: 2025-12-08T15:19:56.823Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 2760
File: apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx:278-281
Timestamp: 2025-12-08T15:19:56.823Z
Learning: In apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx, the tableState search parameter uses intentional double-encoding: the parameter value contains a URL-encoded URLSearchParams string, so decodeURIComponent(value("tableState") ?? "") is required to fully decode it before parsing with new URLSearchParams(). This pattern allows bundling multiple filter/pagination params as a single search parameter.
Applied to files:
apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx
📚 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} : Export tasks with unique IDs within the project to enable proper task discovery and execution
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/types.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.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 `tasks.trigger()` with type-only imports to trigger tasks from backend code without importing the task implementation
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/types.tsapps/webapp/app/runEngine/services/triggerTask.server.tsapps/webapp/test/engine/triggerTask.test.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 `tasks.batchTrigger()` to trigger multiple runs of a single task with different payloads
Applied to files:
packages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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 `batch.triggerAndWait()` to batch trigger multiple different tasks and wait for results
Applied to files:
packages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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 `yourTask.triggerAndWait()` to trigger a task and wait for its result from a parent task
Applied to files:
packages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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 `batch.triggerByTaskAndWait()` to batch trigger tasks by passing task instances and wait for results
Applied to files:
packages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tspackages/trigger-sdk/src/v3/shared.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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 `yourTask.batchTriggerAndWait()` to batch trigger tasks and wait for all results from a parent task
Applied to files:
packages/core/src/v3/types/tasks.tsapps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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 `yourTask.batchTrigger()` to trigger multiple runs of a task from inside another task
Applied to files:
apps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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} : Subscribe to run updates using `runs.subscribeToRun()` for realtime monitoring of task execution
Applied to files:
apps/webapp/app/runEngine/types.tsinternal-packages/run-engine/src/engine/types.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tsinternal-packages/run-engine/src/engine/tests/debounce.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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 `.withStreams()` to subscribe to realtime streams from task metadata in addition to run changes
Applied to files:
internal-packages/run-engine/src/engine/types.tsapps/webapp/app/runEngine/services/triggerTask.server.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/test/engine/triggerTask.test.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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:
internal-packages/run-engine/src/engine/types.tsapps/webapp/package.jsoninternal-packages/run-engine/src/engine/index.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 OpenTelemetry instrumentations and exporters in trigger.config.ts for enhanced logging
Applied to files:
internal-packages/run-engine/src/engine/types.tsinternal-packages/run-engine/src/engine/index.tsapps/webapp/app/runEngine/concerns/traceEvents.server.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:
internal-packages/run-engine/src/engine/types.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: Leverage the PostgreSQL database through the `trigger.dev/database` Prisma 6.14.0 client in the webapp for all data access patterns
Applied to files:
internal-packages/run-engine/src/engine/types.tsai/references/migrations.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 global retry settings in trigger.config.ts using `retries` object with defaults for all tasks
Applied to files:
internal-packages/run-engine/src/engine/types.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 `batch.trigger()` to trigger multiple different tasks at once from backend code
Applied to files:
internal-packages/run-engine/src/engine/types.tsdocs/triggering.mdxinternal-packages/run-engine/src/engine/index.tspackages/trigger-sdk/src/v3/shared.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/app/**/*.{ts,tsx} : Access all environment variables through the `env` export of `env.server.ts` instead of directly accessing `process.env` in the Trigger.dev webapp
Applied to files:
apps/webapp/app/env.server.tsapps/webapp/package.json
📚 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 : Specify runtime environment (node or bun) in trigger.config.ts using the `runtime` property
Applied to files:
apps/webapp/app/env.server.ts
📚 Learning: 2025-11-14T16:03:06.917Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 2681
File: apps/webapp/app/services/platform.v3.server.ts:258-302
Timestamp: 2025-11-14T16:03:06.917Z
Learning: In `apps/webapp/app/services/platform.v3.server.ts`, the `getDefaultEnvironmentConcurrencyLimit` function intentionally throws an error (rather than falling back to org.maximumConcurrencyLimit) when the billing client returns undefined plan limits. This fail-fast behavior prevents users from receiving more concurrency than their plan entitles them to. The org.maximumConcurrencyLimit fallback is only for self-hosted deployments where no billing client exists.
Applied to files:
apps/webapp/app/env.server.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} : Control concurrency using the `queue` property with `concurrencyLimit` option
Applied to files:
docs/triggering.mdx
📚 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} : Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp
Applied to files:
apps/webapp/package.json
📚 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/core,apps/webapp}/**/*.{ts,tsx} : Use zod for validation in packages/core and apps/webapp
Applied to files:
apps/webapp/package.json
📚 Learning: 2025-11-26T14:40:07.146Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 2710
File: packages/schema-to-json/package.json:0-0
Timestamp: 2025-11-26T14:40:07.146Z
Learning: Node.js 24+ has native TypeScript support and can execute .ts files directly without tsx or ts-node for scripts that use only erasable TypeScript syntax (type annotations, interfaces, etc.). The trigger.dev repository uses Node.js 24.11.1+ and scripts like updateVersion.ts can be run with `node` instead of `tsx`.
Applied to files:
apps/webapp/package.json
📚 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 webapp at apps/webapp is a Remix 2.1 application using Node.js v20
Applied to files:
apps/webapp/package.json
📚 Learning: 2025-11-27T16:27:48.109Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T16:27:48.109Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for unit tests
Applied to files:
apps/webapp/package.json
📚 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 **/*.{test,spec}.{ts,tsx} : Use vitest for all tests in the Trigger.dev repository
Applied to files:
apps/webapp/package.json
📚 Learning: 2025-11-27T16:26:44.496Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/executing-commands.mdc:0-0
Timestamp: 2025-11-27T16:26:44.496Z
Learning: For running tests, navigate into the package directory and run `pnpm run test --run` to enable single-file test execution (e.g., `pnpm run test ./src/engine/tests/ttl.test.ts --run`)
Applied to files:
apps/webapp/package.jsoninternal-packages/run-engine/src/engine/tests/debounce.test.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 build process in trigger.config.ts using `build` object with external packages, extensions, and JSX settings
Applied to files:
apps/webapp/package.json
📚 Learning: 2025-11-27T16:27:48.109Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T16:27:48.109Z
Learning: pnpm version `10.23.0` and Node.js version `20.11.1` are required for development
Applied to files:
apps/webapp/package.json
📚 Learning: 2025-07-12T18:06:04.133Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 2264
File: apps/webapp/app/services/runsRepository.server.ts:172-174
Timestamp: 2025-07-12T18:06:04.133Z
Learning: In apps/webapp/app/services/runsRepository.server.ts, the in-memory status filtering after fetching runs from Prisma is intentionally used as a workaround for ClickHouse data delays. This approach is acceptable because the result set is limited to a maximum of 100 runs due to pagination, making the performance impact negligible.
Applied to files:
internal-packages/run-engine/src/engine/systems/delayedRunSystem.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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 internal-packages/database/**/*.{ts,tsx} : Use Prisma for database interactions in internal-packages/database with PostgreSQL
Applied to files:
ai/references/migrations.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/**/*.{ts,tsx,js,jsx} : Use `schedules.task()` for scheduled/cron tasks instead of regular `task()`
Applied to files:
apps/webapp/app/runEngine/services/triggerTask.server.tsapps/webapp/test/engine/triggerTask.test.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 `batch.triggerByTask()` to batch trigger tasks by passing task instances for static task sets
Applied to files:
apps/webapp/app/runEngine/services/triggerTask.server.tspackages/trigger-sdk/src/v3/shared.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 `runs.subscribeToBatch()` to subscribe to changes for all runs in a batch
Applied to files:
internal-packages/run-engine/src/engine/index.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 `yourTask.trigger()` to trigger a task from inside another task with specified payload
Applied to files:
packages/trigger-sdk/src/v3/shared.ts
📚 Learning: 2025-10-08T11:48:12.327Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2593
File: packages/core/src/v3/workers/warmStartClient.ts:168-170
Timestamp: 2025-10-08T11:48:12.327Z
Learning: The trigger.dev runners execute only in Node 21 and 22 environments, so modern Node.js APIs like AbortSignal.any (introduced in v20.3.0) are supported.
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
🧬 Code graph analysis (7)
apps/webapp/app/v3/runEngine.server.ts (2)
apps/webapp/app/env.server.ts (1)
env(1285-1285)apps/supervisor/src/env.ts (1)
env(119-119)
internal-packages/run-engine/src/engine/types.ts (2)
internal-packages/redis/src/index.ts (1)
RedisOptions(4-4)packages/core/src/v3/schemas/common.ts (2)
TaskRun(209-234)TaskRun(236-236)
internal-packages/run-engine/src/engine/systems/delayedRunSystem.ts (1)
internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts (1)
getLatestExecutionSnapshot(95-113)
internal-packages/run-engine/src/engine/index.ts (1)
internal-packages/run-engine/src/engine/systems/debounceSystem.ts (1)
DebounceSystem(59-542)
apps/webapp/test/engine/triggerTask.test.ts (1)
apps/webapp/app/runEngine/types.ts (2)
TriggerTaskRequest(24-30)TracedEventSpan(124-140)
internal-packages/run-engine/src/engine/tests/debounce.test.ts (4)
internal-packages/testcontainers/src/index.ts (1)
containerTest(233-241)internal-packages/run-engine/src/engine/tests/setup.ts (2)
setupAuthenticatedEnvironment(21-82)setupBackgroundWorker(84-293)apps/webapp/app/v3/runEngine.server.ts (2)
engine(11-11)RunEngine(13-13)internal-packages/run-engine/src/engine/index.ts (1)
RunEngine(76-2055)
apps/webapp/app/runEngine/concerns/traceEvents.server.ts (1)
apps/webapp/app/runEngine/types.ts (1)
TracedEventSpan(124-140)
⏰ 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). (23)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 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 (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- 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 (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 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 (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: typecheck / typecheck
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (36)
packages/trigger-sdk/package.json (1)
131-131: LGTM!Formatting change adds trailing newline, following standard conventions. No functional impact.
apps/webapp/package.json (1)
17-17: LGTM!Memory boost for TypeScript compilation is appropriate given the expanded codebase with debounce features. The
cross-envwrapper ensures cross-platform compatibility.packages/core/src/v3/schemas/runEngine.ts (1)
16-16: LGTM!The
DELAYEDstatus is correctly added toTaskRunExecutionStatusand aligns with the Prisma schema enum addition. Type constraints are satisfied.internal-packages/database/prisma/schema.prisma (2)
584-586: LGTM!The
debounceJSON field is properly documented and appropriately nullable for backward compatibility. This aligns with the migration and broader debounce feature implementation.
954-955: LGTM!The
DELAYEDenum variant is well-positioned in the execution status flow and clearly documented. This matches the migration and supports the debounce workflow.packages/core/src/v3/types/tasks.ts (1)
899-932: LGTM!The
debounceoption is well-documented with clear examples and explanations. The type structure is straightforward and consistent with other trigger options. The scoping behavior is clearly explained.packages/core/src/v3/schemas/api.ts (1)
206-211: LGTM!The
debouncefield in the API schema correctly matches the TypeScript type definition intasks.ts. The structure is consistent and properly optional.ai/references/migrations.md (1)
1-121: LGTM!Excellent documentation of the Prisma migration workflow. The step-by-step instructions clearly explain the cleanup process for extraneous edits, and the example perfectly matches the actual migration in this PR.
internal-packages/database/prisma/migrations/20251216225303_add_debounce_and_delayed_status/migration.sql (1)
1-5: LGTM!Clean migration that precisely matches the Prisma schema changes. The use of JSONB for the
debouncecolumn is appropriate for storing structured debounce options. This follows the workflow documented inmigrations.md.internal-packages/run-engine/src/engine/systems/waitpointSystem.ts (1)
579-590: Correctly skipping DELAYED runs in waitpoint continuationTreating
DELAYEDlike other non-progressing states here (debug +status: "skipped") is the right behavior so waitpoint completion doesn’t prematurely resume delayed runs.apps/webapp/app/v3/runEngine.server.ts (1)
185-188: RunEngine debounce configuration wiring looks correct
maxDebounceDurationMsis plumbed from the validated env and matches the newRunEngineOptions["debounce"]shape; no issues here..cursor/rules/migrations.mdc (1)
1-6: Migration rules doc looks goodFront‑matter and the pointer to
ai/references/migrations.mdare clear and consistent with other rule files.docs/triggering.mdx (1)
834-893: Debounce documentation is clear and aligned with the feature designThe section accurately describes debounce semantics (task‑scoped keys, first‑payload wins, DELAYED runs, triggerAndWait behavior, and idempotency precedence) and includes solid examples.
internal-packages/run-engine/src/engine/types.ts (1)
10-11: Engine debounce options and callback typing look soundThe new
debounceblock onRunEngineOptionsand thedebounce/onDebouncedfields onTriggerParamsare well‑typed and consistent with the debounce flow (usingTaskRun/Waitpointfor the callback). This should integrate cleanly with the new DebounceSystem and tracing hooks.Also applies to: 86-90, 172-185
packages/trigger-sdk/src/v3/shared.ts (1)
2269-2290: triggerAndWait debounce propagation matches trigger()Including
debounce: options?.debouncein thetriggerAndWait_internalrequest keeps the semantics betweentrigger()andtriggerAndWait()aligned and enables the debounced wait behavior described in the docs.apps/webapp/app/runEngine/types.ts (2)
134-140: Span API extension for debounced runs is reasonableAdding
stop(): voidtoTracedEventSpangives the trigger path a clean way to end the original span when a debounced run is reused, without forcing an event write. This matches the intended debounce tracing behavior.
159-169: traceDebouncedRun hook completes the tracing surfaceThe new
traceDebouncedRunmethod mirrorstraceIdempotentRunand exposes the right context (existingRun,debounceKey, status flags) for debounced runs, which should make implementing debounced tracing straightforward.apps/webapp/test/engine/triggerTask.test.ts (1)
69-137: LGTM! Mock implementations correctly extended for debounce support.The
MockTraceEventConcernclass properly implements all three tracing methods with the newstopbinding and the newtraceDebouncedRunmethod. The mock signature matches theTraceEventConcerninterface.internal-packages/run-engine/src/engine/systems/delayedRunSystem.ts (1)
100-138: Lock coordination withskipRunLockprevents deadlock.The refactored
enqueueDelayedRuncorrectly acquires the run lock first, then passesskipRunLock: truetoenqueueRunto avoid deadlock since the outer lock is already held. The status check before enqueue properly handles race conditions with debounce rescheduling.apps/webapp/app/presenters/v3/SpanPresenter.server.ts (1)
361-362: Debounce field correctly added to selection set.The selection set update properly includes the debounce field for retrieval.
apps/webapp/app/runEngine/concerns/traceEvents.server.ts (2)
54-54: LGTM! Stop binding correctly added to span objects.The
stop: event.stop.bind(event)binding is correctly added to bothtraceRunandtraceIdempotentRun, matching the updatedTracedEventSpantype definition.Also applies to: 120-120
128-192: LGTM! Well-structured debounced tracing implementation.The
traceDebouncedRunmethod correctly mirrors the idempotent run tracing pattern with appropriate debounce-specific messaging. The icon choice and attribute setup are consistent with existing patterns.Note: There is structural similarity with
traceIdempotentRun. If additional similar tracing methods are added in the future, consider extracting a shared helper to reduce duplication.apps/webapp/app/runEngine/services/triggerTask.server.ts (2)
163-176: LGTM! Debounce delay validation is well-structured.The delay parsing correctly falls back from explicit
delaytodebounce.delay, and the validation properly enforces that debounce requires a valid delay duration. Error messages are informative and include the provided values.
382-386: LGTM! Proper span lifecycle management for debounced runs.The logic correctly stops the outer span when the run was debounced (detected by differing
friendlyId), preventing duplicate trace events since the debounced span is created separately viaonDebounced.internal-packages/run-engine/src/engine/tests/debounce.test.ts (1)
11-96: LGTM!Comprehensive test for basic debounce creation. Properly verifies the DELAYED status, debounce metadata storage in DB, and execution snapshot status.
internal-packages/run-engine/src/engine/systems/debounceSystem.ts (4)
10-48: LGTM!Type definitions are well-structured. Uses types over interfaces as per coding guidelines, and the discriminated union for
DebounceResultis a good pattern for handling the three possible outcomes.
102-158: LGTM!The atomic claim implementation using
SET NX PXis correct for distributed coordination. The handling of the "pending" state (another server creating) and the edge case where the key expires between SET and GET is well-implemented.
357-435: LGTM!The
handleDebouncemethod correctly orchestrates the distributed debounce flow with atomic claiming, waiting for pending claims, and handling existing runs. Good use of tracing for observability.
445-515: LGTM!The registration method correctly verifies claim ownership before overwriting, preventing race conditions where the claim expired and another server took over. Good use of TTL with buffer.
internal-packages/run-engine/src/engine/index.ts (7)
50-50: LGTM!Import is correctly placed with other system imports.
302-308: LGTM!DebounceSystem initialization correctly uses shared resources, falls back to
runLock.redisif debounce-specific Redis config isn't provided, and sets a sensible default max debounce duration of 1 hour.
452-506: LGTM!The debounce handling in the trigger method correctly handles all three outcomes:
existing: Returns the existing run and blocks parent if needed for triggerAndWaitmax_duration_exceeded: Continues to create a new run with attribute set for observabilitynew: Stores claimId for later registrationThe
onDebouncedcallback integration for creating trace spans is well-designed.
579-590: LGTM!Debounce metadata is correctly stored with the run, including
createdAtfor tracking max duration. The execution snapshot status correctly distinguishes betweenDELAYEDandRUN_CREATED.
660-680: LGTM!The debounce registration correctly happens after the run is created and delay is scheduled. The warning log for a lost claim is appropriate, and continuing despite registration failure is acceptable since the run already exists.
1406-1408: LGTM!DebounceSystem Redis connection is properly closed during engine shutdown.
1882-1884: LGTM!The
DELAYEDstatus is correctly handled:
- Heartbeat handler throws
NotImplementedErrorsince delayed runs shouldn't be heartbeating- Repair handler returns early since delayed runs don't need repair
Both are consistent with the behavior for
RUN_CREATED.Also applies to: 1925-1926
internal-packages/run-engine/src/engine/systems/debounceSystem.ts
Outdated
Show resolved
Hide resolved
Vibe Kanban Review CompleteYour code review is ready! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/cli-v3/src/build/manifests.ts (1)
55-58: Verify necessity of the Uint8Array cast.The explicit cast to
Uint8Arraymay be unnecessary sincereadFilereturns aBuffer, which already extendsUint8Arrayand is compatible withcreateHash().update()(acceptsBinaryLike). Consider investigating whether this cast is working around a type resolution issue that could be fixed at the root cause.If the cast is needed due to TypeScript version or configuration constraints, consider adding a comment explaining why it's necessary.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
references/hello-world/src/trigger/debounce.tsis excluded by!references/**
📒 Files selected for processing (7)
.changeset/ninety-cows-lay.md(1 hunks)packages/cli-v3/src/build/manifests.ts(1 hunks)packages/cli-v3/src/entryPoints/dev-run-controller.ts(1 hunks)packages/cli-v3/src/entryPoints/managed/execution.ts(1 hunks)packages/core/src/v3/schemas/api.ts(2 hunks)packages/core/src/v3/zodSocket.ts(1 hunks)packages/trigger-sdk/src/v3/shared.ts(12 hunks)
✅ Files skipped from review due to trivial changes (2)
- packages/core/src/v3/zodSocket.ts
- .changeset/ninety-cows-lay.md
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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/entryPoints/dev-run-controller.tspackages/cli-v3/src/entryPoints/managed/execution.tspackages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.tspackages/cli-v3/src/build/manifests.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Files:
packages/cli-v3/src/entryPoints/dev-run-controller.tspackages/cli-v3/src/entryPoints/managed/execution.tspackages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.tspackages/cli-v3/src/build/manifests.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier
Files:
packages/cli-v3/src/entryPoints/dev-run-controller.tspackages/cli-v3/src/entryPoints/managed/execution.tspackages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.tspackages/cli-v3/src/build/manifests.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use zod for validation in packages/core and apps/webapp
Files:
packages/core/src/v3/schemas/api.ts
packages/trigger-sdk/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code
Files:
packages/trigger-sdk/src/v3/shared.ts
🧠 Learnings (16)
📓 Common learnings
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} : Attach metadata to task runs using the metadata option when triggering, and access/update it inside runs using metadata functions
📚 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 `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation
Applied to files:
packages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.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/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.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 `tasks.batchTrigger()` to trigger multiple runs of a single task with different payloads
Applied to files:
packages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.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 `idempotencyKeys.create()` to create idempotency keys for preventing duplicate task executions
Applied to files:
packages/core/src/v3/schemas/api.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 metadata methods (set, del, replace, append, remove, increment, decrement, stream, flush) to update metadata during task execution
Applied to files:
packages/core/src/v3/schemas/api.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 `idempotencyKeyTTL` option to define a time window during which duplicate triggers return the original run
Applied to files:
packages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.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} : Limit task duration using the `maxDuration` property (in seconds)
Applied to files:
packages/core/src/v3/schemas/api.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 `batch.triggerByTaskAndWait()` to batch trigger tasks by passing task instances and wait for results
Applied to files:
packages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.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} : Attach metadata to task runs using the metadata option when triggering, and access/update it inside runs using metadata functions
Applied to files:
packages/core/src/v3/schemas/api.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 `batch.triggerByTask()` to batch trigger tasks by passing task instances for static task sets
Applied to files:
packages/core/src/v3/schemas/api.tspackages/trigger-sdk/src/v3/shared.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/trigger-sdk/src/v3/shared.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 `batch.triggerAndWait()` to batch trigger multiple different tasks and wait for results
Applied to files:
packages/trigger-sdk/src/v3/shared.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 `batch.trigger()` to trigger multiple different tasks at once from backend code
Applied to files:
packages/trigger-sdk/src/v3/shared.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} : Export tasks with unique IDs within the project to enable proper task discovery and execution
Applied to files:
packages/trigger-sdk/src/v3/shared.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 `yourTask.batchTriggerAndWait()` to batch trigger tasks and wait for all results from a parent task
Applied to files:
packages/trigger-sdk/src/v3/shared.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). (24)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- 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 (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: typecheck / typecheck
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: Cursor Bugbot
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
packages/cli-v3/src/entryPoints/managed/execution.ts (1)
375-384: LGTM! Correct handling of the new DELAYED status.The addition of
DELAYEDas an invalid execution status alongsideRUN_CREATEDis correct. Both represent pre-execution states (initial creation and delayed/debounced waiting), so encountering them during active execution processing indicates an error condition that should abort the execution. The fall-through pattern appropriately shares the same handling logic.packages/cli-v3/src/entryPoints/dev-run-controller.ts (1)
429-435: LGTM! Correct handling of new DELAYED status.The addition of the
DELAYEDcase (along withQUEUED) to the switch statement is appropriate for the dev environment. Since delayed runs are waiting for the debounce delay to elapse, no action is needed in the dev controller until they transition toEXECUTING. The fall-through behavior is consistent with other statuses that don't require immediate handling, and theassertExhaustivecall ensures type safety.packages/trigger-sdk/src/v3/shared.ts (1)
652-652: LGTM! Debounce field properly threaded through all trigger paths.The debounce option is consistently propagated through all batch trigger variants (by ID and by task), streaming transforms, and internal trigger functions. The use of optional chaining (
?.) is appropriate since debounce is an optional feature.Also applies to: 908-908, 1168-1168, 1429-1429, 1765-1765, 1817-1817, 1868-1868, 1919-1919, 1972-1972, 2025-2025, 2067-2067, 2299-2299
internal-packages/run-engine/src/engine/systems/debounceSystem.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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)
internal-packages/run-engine/src/engine/tests/delays.test.ts (1)
76-79: Consider checking bothrun.statusandexecutionData.snapshot.executionStatusfor consistency.The TTL test (line 260) and cancelling test (line 363) verify both the returned
run.statusand the fetchedexecutionData.snapshot.executionStatusare DELAYED. For consistency and thoroughness, consider adding therun.statuscheck to these assertions as well.Example for lines 76-79:
//should be delayed but not queued yet const executionData = await engine.getRunExecutionData({ runId: run.id }); assertNonNullable(executionData); expect(executionData.snapshot.executionStatus).toBe("DELAYED"); +expect(run.status).toBe("DELAYED");Apply similar changes at lines 158-161 and 173-176.
Also applies to: 158-161, 173-176
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal-packages/run-engine/src/engine/tests/delays.test.ts(5 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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:
internal-packages/run-engine/src/engine/tests/delays.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Files:
internal-packages/run-engine/src/engine/tests/delays.test.ts
**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use vitest for all tests in the Trigger.dev repository
Files:
internal-packages/run-engine/src/engine/tests/delays.test.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier
Files:
internal-packages/run-engine/src/engine/tests/delays.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.{ts,tsx,js,jsx}: Test files should live beside the files under test and use descriptivedescribeanditblocks
Avoid mocks or stubs in tests; use helpers from@internal/testcontainerswhen Redis or Postgres are needed
Use vitest for unit tests
Files:
internal-packages/run-engine/src/engine/tests/delays.test.ts
🧠 Learnings (3)
📓 Common learnings
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} : Attach metadata to task runs using the metadata option when triggering, and access/update it inside runs using metadata functions
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 metadata methods (set, del, replace, append, remove, increment, decrement, stream, flush) to update metadata during task execution
📚 Learning: 2025-11-27T16:26:44.496Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/executing-commands.mdc:0-0
Timestamp: 2025-11-27T16:26:44.496Z
Learning: For running tests, navigate into the package directory and run `pnpm run test --run` to enable single-file test execution (e.g., `pnpm run test ./src/engine/tests/ttl.test.ts --run`)
Applied to files:
internal-packages/run-engine/src/engine/tests/delays.test.ts
📚 Learning: 2025-07-12T18:06:04.133Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 2264
File: apps/webapp/app/services/runsRepository.server.ts:172-174
Timestamp: 2025-07-12T18:06:04.133Z
Learning: In apps/webapp/app/services/runsRepository.server.ts, the in-memory status filtering after fetching runs from Prisma is intentionally used as a workaround for ClickHouse data delays. This approach is acceptable because the result set is limited to a maximum of 100 runs due to pagination, making the performance impact negligible.
Applied to files:
internal-packages/run-engine/src/engine/tests/delays.test.ts
🧬 Code graph analysis (1)
internal-packages/run-engine/src/engine/tests/delays.test.ts (2)
apps/webapp/app/v3/runEngine.server.ts (1)
engine(11-11)internal-packages/testcontainers/src/utils.ts (1)
assertNonNullable(173-176)
⏰ 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). (24)
- GitHub Check: Cursor Bugbot
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 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 (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- 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: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: typecheck / typecheck
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
internal-packages/run-engine/src/engine/tests/delays.test.ts (1)
76-79: LGTM! Test expectations correctly updated to reflect the new DELAYED status.The changes properly update all delay-related test expectations from the legacy RUN_CREATED status to the new DELAYED status, aligning with the PR's introduction of a dedicated DELAYED execution state. The tests continue to provide comprehensive coverage of delay scenarios including basic delays, rescheduling, TTL expiration, and cancellation.
Also applies to: 158-161, 173-176, 256-260, 359-363
There was a problem hiding this 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
♻️ Duplicate comments (2)
internal-packages/run-engine/src/engine/systems/debounceSystem.ts (1)
294-300: Verify that parseNaturalLanguageDuration supports millisecond durations.Tests use millisecond delay values like "300ms" and "500ms", but a previous review noted that
parseNaturalLanguageDurationmay only supportw/d/hr/h/m/sunits. If millisecond durations are not supported, the tests and user-provided debounce delays with "ms" suffix will fail or be treated as invalid.Please run the following script to verify millisecond support in
parseNaturalLanguageDuration:#!/bin/bash # Check the implementation of parseNaturalLanguageDuration to verify supported time units rg -n "parseNaturalLanguageDuration" packages/core/src/v3/isomorphic -A 30 | head -80internal-packages/run-engine/src/engine/tests/debounce.test.ts (1)
1-8: Missingviimport from vitest.The
viglobal is used on line 8 but not imported. Addvito the import statement.Apply this diff:
-import { expect } from "vitest"; +import { expect, vi } from "vitest";
🧹 Nitpick comments (1)
packages/core/src/v3/types/tasks.ts (1)
900-936: Well-structured debounce option with comprehensive documentation.The type definition is clean and follows existing patterns in
TriggerOptions. The inline documentation is excellent, with clear examples and constraint details.Optional documentation enhancements:
Consider documenting the behavior when both the top-level
delayoption (line 797) anddebounce.delayare specified. Additionally, the PR summary mentions that "idempotency is checked first" when bothidempotencyKeyanddebounceare provided—clarifying this precedence in the JSDoc could help users understand the interaction.Verify zod schema validation:
Ensure that corresponding zod schema validation exists in
packages/core/src/v3/schemas/api.tsfor:
- The
delayfield format validation (duration string pattern)- The
keyfield max length constraint (512 characters)- The minimum delay value (1 second)
Based on coding guidelines for packages/core.
#!/bin/bash # Description: Verify zod schema validation for the debounce field exists # Search for debounce schema definitions in the schemas directory echo "=== Searching for debounce schema definitions ===" rg -n -C5 'debounce' packages/core/src/v3/schemas/api.ts echo "" echo "=== Checking for delay string validation ===" rg -n -C3 'z\.(string|object).*delay' packages/core/src/v3/schemas/ echo "" echo "=== Checking for key length validation ===" rg -n -C3 '(max|length).*512' packages/core/src/v3/schemas/
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
references/hello-world/src/trigger/debounce.tsis excluded by!references/**
📒 Files selected for processing (4)
internal-packages/run-engine/src/engine/systems/debounceSystem.ts(1 hunks)internal-packages/run-engine/src/engine/tests/debounce.test.ts(1 hunks)packages/core/src/v3/schemas/api.ts(2 hunks)packages/core/src/v3/types/tasks.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/core/src/v3/schemas/api.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{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/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsinternal-packages/run-engine/src/engine/tests/debounce.test.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use zod for validation in packages/core and apps/webapp
Files:
packages/core/src/v3/types/tasks.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsinternal-packages/run-engine/src/engine/tests/debounce.test.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier
Files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsinternal-packages/run-engine/src/engine/tests/debounce.test.ts
**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use vitest for all tests in the Trigger.dev repository
Files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.{ts,tsx,js,jsx}: Test files should live beside the files under test and use descriptivedescribeanditblocks
Avoid mocks or stubs in tests; use helpers from@internal/testcontainerswhen Redis or Postgres are needed
Use vitest for unit tests
Files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
🧠 Learnings (27)
📚 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/core/src/v3/types/tasks.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} : Attach metadata to task runs using the metadata option when triggering, and access/update it inside runs using metadata functions
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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 `idempotencyKeyTTL` option to define a time window during which duplicate triggers return the original run
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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} : Limit task duration using the `maxDuration` property (in seconds)
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.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 `tasks.trigger()` with type-only imports to trigger tasks from backend code without importing the task implementation
Applied to files:
packages/core/src/v3/types/tasks.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 `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation
Applied to files:
packages/core/src/v3/types/tasks.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} : Export tasks with unique IDs within the project to enable proper task discovery and execution
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/systems/debounceSystem.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 `tasks.batchTrigger()` to trigger multiple runs of a single task with different payloads
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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 metadata methods (set, del, replace, append, remove, increment, decrement, stream, flush) to update metadata during task execution
Applied to files:
packages/core/src/v3/types/tasks.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/core/src/v3/types/tasks.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 `batch.triggerAndWait()` to batch trigger multiple different tasks and wait for results
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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 `yourTask.triggerAndWait()` to trigger a task and wait for its result from a parent task
Applied to files:
packages/core/src/v3/types/tasks.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 `batch.triggerByTaskAndWait()` to batch trigger tasks by passing task instances and wait for results
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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 `yourTask.batchTriggerAndWait()` to batch trigger tasks and wait for all results from a parent task
Applied to files:
packages/core/src/v3/types/tasks.tsinternal-packages/run-engine/src/engine/tests/debounce.test.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} : Configure task retry behavior using the `retry` property with options like maxAttempts, factor, and timeout values
Applied to files:
packages/core/src/v3/types/tasks.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 `idempotencyKeys.create()` to create idempotency keys for preventing duplicate task executions
Applied to files:
packages/core/src/v3/types/tasks.ts
📚 Learning: 2025-11-27T16:26:44.496Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/executing-commands.mdc:0-0
Timestamp: 2025-11-27T16:26:44.496Z
Learning: For running tests, navigate into the package directory and run `pnpm run test --run` to enable single-file test execution (e.g., `pnpm run test ./src/engine/tests/ttl.test.ts --run`)
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
📚 Learning: 2025-11-27T16:27:48.109Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T16:27:48.109Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for unit tests
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.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 **/*.{test,spec}.{ts,tsx} : Use vitest for all tests in the Trigger.dev repository
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
📚 Learning: 2025-11-27T16:27:48.109Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T16:27:48.109Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocks or stubs in tests; use helpers from `internal/testcontainers` when Redis or Postgres are needed
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.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/**/*.test.{ts,tsx} : Test files should only import classes and functions from `app/**/*.ts` files and should not import `env.server.ts` directly or indirectly; pass configuration through options instead
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
📚 Learning: 2025-11-27T16:27:48.109Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T16:27:48.109Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Test files should live beside the files under test and use descriptive `describe` and `it` blocks
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
📚 Learning: 2025-10-08T11:48:12.327Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2593
File: packages/core/src/v3/workers/warmStartClient.ts:168-170
Timestamp: 2025-10-08T11:48:12.327Z
Learning: The trigger.dev runners execute only in Node 21 and 22 environments, so modern Node.js APIs like AbortSignal.any (introduced in v20.3.0) are supported.
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.ts
📚 Learning: 2025-07-12T18:06:04.133Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 2264
File: apps/webapp/app/services/runsRepository.server.ts:172-174
Timestamp: 2025-07-12T18:06:04.133Z
Learning: In apps/webapp/app/services/runsRepository.server.ts, the in-memory status filtering after fetching runs from Prisma is intentionally used as a workaround for ClickHouse data delays. This approach is acceptable because the result set is limited to a maximum of 100 runs due to pagination, making the performance impact negligible.
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.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 `yourTask.batchTrigger()` to trigger multiple runs of a task from inside another task
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.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} : Subscribe to run updates using `runs.subscribeToRun()` for realtime monitoring of task execution
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.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} : Control concurrency using the `queue` property with `concurrencyLimit` option
Applied to files:
internal-packages/run-engine/src/engine/tests/debounce.test.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). (24)
- GitHub Check: Cursor Bugbot
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 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 (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 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 (1, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: typecheck / typecheck
- GitHub Check: Analyze (javascript-typescript)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Canceled delayed runs can still enqueue
Delayed runs now start with executionStatus set to DELAYED instead of the legacy RUN_CREATED. Some run-cancel logic relies on “initial state” checks that only match RUN_CREATED to call preventDelayedRunFromBeingEnqueued, so canceling a delayed run can leave the scheduled enqueueDelayedRun job active and enqueue the run anyway later.
internal-packages/run-engine/src/engine/index.ts#L507-L606
trigger.dev/internal-packages/run-engine/src/engine/index.ts
Lines 507 to 606 in f048420
| const status = delayUntil ? "DELAYED" : "PENDING"; | |
| //create run | |
| let taskRun: TaskRun & { associatedWaitpoint: Waitpoint | null }; | |
| const taskRunId = RunId.fromFriendlyId(friendlyId); | |
| try { | |
| taskRun = await prisma.taskRun.create({ | |
| include: { | |
| associatedWaitpoint: true, | |
| }, | |
| data: { | |
| id: taskRunId, | |
| engine: "V2", | |
| status, | |
| friendlyId, | |
| runtimeEnvironmentId: environment.id, | |
| environmentType: environment.type, | |
| organizationId: environment.organization.id, | |
| projectId: environment.project.id, | |
| idempotencyKey, | |
| idempotencyKeyExpiresAt, | |
| taskIdentifier, | |
| payload, | |
| payloadType, | |
| context, | |
| traceContext, | |
| traceId, | |
| spanId, | |
| parentSpanId, | |
| lockedToVersionId, | |
| taskVersion, | |
| sdkVersion, | |
| cliVersion, | |
| concurrencyKey, | |
| queue, | |
| lockedQueueId, | |
| workerQueue, | |
| isTest, | |
| delayUntil, | |
| queuedAt, | |
| maxAttempts, | |
| taskEventStore, | |
| priorityMs, | |
| queueTimestamp: queueTimestamp ?? delayUntil ?? new Date(), | |
| ttl, | |
| tags: | |
| tags.length === 0 | |
| ? undefined | |
| : { | |
| connect: tags, | |
| }, | |
| runTags: tags.length === 0 ? undefined : tags.map((tag) => tag.name), | |
| oneTimeUseToken, | |
| parentTaskRunId, | |
| rootTaskRunId, | |
| replayedFromTaskRunFriendlyId, | |
| batchId: batch?.id, | |
| resumeParentOnCompletion, | |
| depth, | |
| metadata, | |
| metadataType, | |
| seedMetadata, | |
| seedMetadataType, | |
| maxDurationInSeconds, | |
| machinePreset: machine, | |
| scheduleId, | |
| scheduleInstanceId, | |
| createdAt, | |
| bulkActionGroupIds: bulkActionId ? [bulkActionId] : undefined, | |
| planType, | |
| realtimeStreamsVersion, | |
| debounce: debounce | |
| ? { | |
| key: debounce.key, | |
| delay: debounce.delay, | |
| createdAt: new Date(), | |
| } | |
| : undefined, | |
| executionSnapshots: { | |
| create: { | |
| engine: "V2", | |
| executionStatus: delayUntil ? "DELAYED" : "RUN_CREATED", | |
| description: delayUntil ? "Run is delayed" : "Run was created", | |
| runStatus: status, | |
| environmentId: environment.id, | |
| environmentType: environment.type, | |
| projectId: environment.project.id, | |
| organizationId: environment.organization.id, | |
| workerId, | |
| runnerId, | |
| }, | |
| }, | |
| associatedWaitpoint: { | |
| create: this.waitpointSystem.buildRunAssociatedWaitpoint({ | |
| projectId: environment.project.id, | |
| environmentId: environment.id, | |
| }), | |
| }, | |
| }, |
Debounced Runs
Overview
Adds support for debounced task runs - when triggering a task with a debounce key, subsequent triggers with the same key will reschedule the existing delayed run instead of creating new runs. This continues until no new triggers occur within the delay window.
Usage
"5s","1m")Works with
triggerAndWait- parent runs correctly block on the debounced run.Behavior
DEBOUNCE_MAX_DURATION_MSenv var (default: 10 minutes)Technical Details (for maintainers)
New Components
DebounceSystem: Manages debounce keys in Redis with atomic claim/register pattern to prevent distributed race conditionsDELAYEDexecution status: New status for runs waiting on a delay (previously usedRUN_CREATED)TaskRun.debounce: JSON column storing debounce optionsKey Implementation Details
debounce:{envId}:{taskId}:{key}) to avoid adding indexes to TaskRun tableSET NXwith pending state) to handle concurrent triggers across serversenqueueDelayedRunacquires run lock and checks status before enqueuing to prevent races with debounce reschedulingRUN_CREATEDstatus still work after deployFiles Changed
internal-packages/run-engine/src/engine/systems/debounceSystem.ts- Core debounce logicinternal-packages/run-engine/src/engine/systems/delayedRunSystem.ts- Delay rescheduling, race protectioninternal-packages/run-engine/src/engine/index.ts- Integration in trigger flowapps/webapp/app/runEngine/services/triggerTask.server.ts- Span handling for debounced triggerspackages/core/src/v3/schemas/api.ts- API schema updatespackages/trigger-sdk/src/v3/shared.ts- SDK types