Skip to content

fix(core): define RunEvent schema and update ApiClient validation#3220

Open
bharathkumar39293 wants to merge 10 commits intotriggerdotdev:mainfrom
bharathkumar39293:fix/run-event-schema-v3
Open

fix(core): define RunEvent schema and update ApiClient validation#3220
bharathkumar39293 wants to merge 10 commits intotriggerdotdev:mainfrom
bharathkumar39293:fix/run-event-schema-v3

Conversation

@bharathkumar39293
Copy link
Contributor

Resolves the internal TODO in

ApiClient
regarding missing schema validation for task run events.

✅ Checklist
I have followed every step in the contributing guide
The PR title follows the convention.
I ran and tested the code works
Technical Cost/Benefit Analysis
Benefit:

Reliability: Replaces z.any() with a strict Zod schema, preventing the SDK from returning invalid or unexpected data formats.
Safety: Addresses two critical edge cases identified during development:
Wrapper Handling: The API returns { events: [...] }. This PR adds the

ListRunEventsResponse
wrapper.
Nullable parentId: Supports null for root spans (stored as null in DB).
Integration: Ensures consistency for tools like the MCP server.
Cost/Risk:

Low Risk: Localized change to @trigger.dev/core. Highly decoupled from other services.
Testing
Unit tests in

packages/core/src/v3/schemas/api-type.test.ts
verify:

Valid event parsing & date coercion.
Failure on invalid data.
Handling of null and undefined for parentId.
Handling of the { events: [...] } response wrapper.
Changelog
@trigger.dev/core: Added

RunEvent
and

ListRunEventsResponse
Zod schemas.
@trigger.dev/core: Updated ApiClient.listRunEvents to use strict validation.

@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2026

🦋 Changeset detected

Latest commit: 838be18

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
@trigger.dev/core Minor
@trigger.dev/build Minor
trigger.dev Minor
@trigger.dev/python Minor
@trigger.dev/redis-worker Minor
@trigger.dev/schema-to-json Minor
@trigger.dev/sdk Minor
@internal/cache Patch
@internal/clickhouse Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch
d3-chat Patch
references-d3-openai-agents Patch
references-nextjs-realtime Patch
references-realtime-hooks-test Patch
references-realtime-streams Patch
references-telemetry Patch
@internal/sdk-compat-tests Patch
@trigger.dev/react-hooks Minor
@trigger.dev/rsc Minor
@trigger.dev/database Minor
@trigger.dev/otlp-importer Minor

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 14, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds new RunEvent-related schemas and exports: TaskEventLevel, NanosecondTimestampSchema (coercing nanoseconds/milliseconds/strings/Date), RunEvent, RunEventWithStringDates, ListRunEventsResponse, and ListRunEventsResponseWithStringDates. ApiClient.listRunEvents now uses ListRunEventsResponse for response validation. Tests expanded to cover RunEvent parsing, timestamp coercion, and response wrapping. Also includes a changeset bump for @trigger.dev/core. Separately, minor CLI deploy string formatting adjustments and internal refactors in realtime streams writer (queued-bytes option rename, record encoding change, seq_num handling, and explicit abort flow) were applied.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: defining a RunEvent schema and updating ApiClient validation, which is the core focus of this PR.
Description check ✅ Passed The description covers testing, changelog, and technical analysis, but is missing the issue number reference (Closes #) and screenshots section that the template requires.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/core/src/v3/apiClient/index.ts (1)

31-31: Consider removing unused import.

RunEvent is imported on line 46 but doesn't appear to be used directly in this file. Only ListRunEventsResponse is used at line 705. The RunEvent type is already part of ListRunEventsResponse.events, so consumers can access it via the response type if needed.

🧹 Proposed fix to remove unused import
 import {
   AddTagsRequestBody,
   ApiDeploymentListOptions,
   ApiDeploymentListResponseItem,
   ApiDeploymentListSearchParams,
   AppendToStreamResponseBody,
   BatchItemNDJSON,
   BatchTaskRunExecutionResult,
   BatchTriggerTaskV3RequestBody,
   BatchTriggerTaskV3Response,
   CanceledRunResponse,
   CompleteWaitpointTokenRequestBody,
   CompleteWaitpointTokenResponseBody,
   CreateBatchRequestBody,
   CreateBatchResponse,
   CreateEnvironmentVariableRequestBody,
   CreateInputStreamWaitpointRequestBody,
   CreateInputStreamWaitpointResponseBody,
   CreateScheduleOptions,
   CreateStreamResponseBody,
   CreateUploadPayloadUrlResponseBody,
   CreateWaitpointTokenRequestBody,
   CreateWaitpointTokenResponseBody,
   DeletedScheduleObject,
   EnvironmentVariableResponseBody,
   EnvironmentVariableWithSecret,
   ListQueueOptions,
   ListRunEventsResponse,
   ListRunResponseItem,
   ListScheduleOptions,
   QueueItem,
   QueueTypeName,
   QueryExecuteRequestBody,
   QueryExecuteResponseBody,
   QueryExecuteCSVResponseBody,
   ReplayRunResponse,
   RescheduleRunRequestBody,
   ResetIdempotencyKeyResponse,
   RetrieveBatchV2Response,
   RetrieveQueueParam,
   RetrieveRunResponse,
   RetrieveRunTraceResponseBody,
-  RunEvent,
   ScheduleObject,
   SendInputStreamResponseBody,
   StreamBatchItemsResponse,

Also applies to: 46-46

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/v3/apiClient/index.ts` at line 31, Remove the unused
RunEvent import from the module: locate the import list that currently includes
RunEvent (alongside ListRunEventsResponse) and delete only RunEvent, leaving
ListRunEventsResponse intact; confirm no other references to the RunEvent
identifier exist in this file (consumers can access it via
ListRunEventsResponse.events) and run a typecheck to ensure the removal is safe.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/core/src/v3/apiClient/index.ts`:
- Line 31: Remove the unused RunEvent import from the module: locate the import
list that currently includes RunEvent (alongside ListRunEventsResponse) and
delete only RunEvent, leaving ListRunEventsResponse intact; confirm no other
references to the RunEvent identifier exist in this file (consumers can access
it via ListRunEventsResponse.events) and run a typecheck to ensure the removal
is safe.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1cd5cb80-8c72-45a8-855e-ee9ff0ad7de8

📥 Commits

Reviewing files that changed from the base of the PR and between 7672e8d and 0d361c8.

📒 Files selected for processing (4)
  • .changeset/define-runevent-schema.md
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
📜 Review details
⏰ 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). (13)
  • 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 (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 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 (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: typecheck / typecheck
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{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

**/*.{ts,tsx}: Use task export syntax: export const myTask = task({ id: 'my-task', run: async (payload) => { ... } })
Use Run Engine 2.0 (@internal/run-engine) and redis-worker for all new work - avoid DEPRECATED zodworker (Graphile-worker wrapper)
Prisma 6.14.0 client and schema use PostgreSQL in internal-packages/database - import only from Prisma client

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.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-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.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-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.ts
**/*.{test,spec}.{ts,tsx}

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

Use vitest for all tests in the Trigger.dev repository

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier before committing

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.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 descriptive describe and it blocks
Tests should avoid mocks or stubs and use the helpers from @internal/testcontainers when Redis or Postgres are needed
Use vitest for running unit tests

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
packages/core/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (packages/core/CLAUDE.md)

Never import the root package (@trigger.dev/core). Always use subpath imports such as @trigger.dev/core/v3, @trigger.dev/core/v3/utils, @trigger.dev/core/logger, or @trigger.dev/core/schemas

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.ts
**/*.test.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx,js}: Use vitest exclusively for testing - never mock anything, use testcontainers instead
Place test files next to source files with naming convention: SourceFile.ts -> SourceFile.test.ts

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use testcontainers for Redis/PostgreSQL testing instead of mocks with redisTest, postgresTest, or containerTest helpers from @internal/testcontainers

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
{packages,integrations}/**/*.{ts,tsx,js,json}

📄 CodeRabbit inference engine (CLAUDE.md)

When modifying public packages (packages/* or integrations/*), add a changeset using pnpm run changeset:add with default patch level for bug fixes and minor changes

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js}: Always import from @trigger.dev/sdk for Trigger.dev tasks - never use @trigger.dev/sdk/v3 or deprecated client.defineJob
Import subpaths only from @trigger.dev/core, never import from root
Add crumbs as you write code using // @crumbs comments or // #region @crumbs blocks for agentcrumbs debug tracing

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/apiClient/index.ts
  • packages/core/src/v3/schemas/api.ts
🧠 Learnings (25)
📓 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} : Use `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation
📚 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:

  • .changeset/define-runevent-schema.md
  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:43:25.254Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: internal-packages/run-engine/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:25.254Z
Learning: Applies to internal-packages/run-engine/src/engine/tests/**/*.test.ts : Implement tests for RunEngine in `src/engine/tests/` using testcontainers for Redis and PostgreSQL containerization

Applied to files:

  • packages/core/src/v3/schemas/api-type.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for running unit tests

Applied to files:

  • packages/core/src/v3/schemas/api-type.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:

  • packages/core/src/v3/schemas/api-type.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
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:

  • packages/core/src/v3/schemas/api-type.test.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: Applies to apps/webapp/app/v3/services/**/*.server.ts : When editing services that branch on `RunEngineVersion` to support both V1 and V2 (e.g., `cancelTaskRun.server.ts`, `batchTriggerV3.server.ts`), only modify V2 code paths

Applied to files:

  • packages/core/src/v3/apiClient/index.ts
📚 Learning: 2026-03-02T12:43:25.254Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: internal-packages/run-engine/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:25.254Z
Learning: Applies to internal-packages/run-engine/src/engine/systems/**/*.ts : Integrate OpenTelemetry tracer and meter instrumentation in RunEngine systems for observability

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to **/*.{ts,tsx} : Use task export syntax: export const myTask = task({ id: 'my-task', run: async (payload) => { ... } })

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 `.withStreams()` to subscribe to realtime streams from task metadata in addition to run changes

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} : Subscribe to run updates using `runs.subscribeToRun()` for realtime monitoring of 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} : 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: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to {packages,integrations}/**/*.{ts,tsx,js,json} : When modifying public packages (packages/* or integrations/*), add a changeset using pnpm run changeset:add with default patch level for bug fixes and minor changes

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} : Export tasks with unique IDs within the project to enable proper task discovery and 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.config.ts : Configure OpenTelemetry instrumentations and exporters in trigger.config.ts for enhanced logging

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to **/*.{ts,tsx} : Use Run Engine 2.0 (internal/run-engine) and redis-worker for all new work - avoid DEPRECATED zodworker (Graphile-worker wrapper)

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: Target Run Engine V2 for all new code; the `engineVersion.server.ts` file determines V1 vs V2 for a given environment

Applied to files:

  • packages/core/src/v3/schemas/api.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:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: V1-only legacy code is located in `app/v3/marqs/`, `app/v3/legacyRunEngineWorker.server.ts`, `app/v3/services/triggerTaskV1.server.ts`, `app/v3/services/cancelTaskRunV1.server.ts`, `app/v3/authenticatedSocketConnection.server.ts`, and `app/v3/sharedSocketConnection.ts`

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: All run lifecycle operations (triggering, completing, cancelling, etc.) should be performed through the singleton run engine instance in `app/v3/runEngine.server.ts` via service calls

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:43:17.177Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: internal-packages/database/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:17.177Z
Learning: New code should always target Prisma RunEngineVersion V2 (run-engine + redis-worker), not V1 (legacy MarQS + Graphile)

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: Applies to apps/webapp/app/v3/*Worker.server.ts : New background job workers should use `trigger.dev/redis-worker` (e.g., `commonWorker.server.ts`, `alertsWorker.server.ts`, `batchTriggerWorker.server.ts`), not zodworker or graphile-worker

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} : Export every task, including subtasks

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 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.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to {packages/core,apps/webapp}/**/*.{ts,tsx} : Use zod for validation in packages/core and apps/webapp

Applied to files:

  • packages/core/src/v3/schemas/api.ts
🔇 Additional comments (9)
packages/core/src/v3/schemas/api.ts (4)

12-13: LGTM!

The imports for TaskEventStyle and SpanEvents are correctly added to support the new RunEvent schema definition.


1644-1645: LGTM!

TaskEventLevel uses z.enum() which produces a TypeScript string union type, consistent with other similar definitions in this file (e.g., RunStatus, AttemptStatus, BatchStatus).


1647-1664: LGTM!

The RunEvent schema is well-structured:

  • Uses .nullish() for parentId to correctly handle root spans where parentId may be null from the DB
  • Uses z.coerce.date() for startTime, consistent with other date fields in this file
  • Properly references existing schemas (TaskEventStyle, TaskEventLevel, SpanEvents)

1666-1670: LGTM!

The ListRunEventsResponse wrapper correctly encapsulates the events array in an object, providing a proper response shape that can be extended in the future without breaking changes.

.changeset/define-runevent-schema.md (1)

1-5: LGTM!

The changeset is properly formatted with patch level, which is appropriate for this bug fix that adds strict schema validation to replace z.any().

packages/core/src/v3/apiClient/index.ts (1)

703-713: LGTM!

The listRunEvents method now uses ListRunEventsResponse schema instead of z.any(), providing strict validation for the API response. This is the core fix for the internal TODO mentioned in the PR objectives.

packages/core/src/v3/schemas/api-type.test.ts (3)

2-2: LGTM!

Imports correctly added for the new schemas to be tested.


143-200: LGTM!

Comprehensive test coverage for RunEvent schema:

  • Valid event parsing with date coercion verification
  • Missing required field detection
  • Invalid enum value rejection
  • Both undefined (missing) and null parentId handling

The tests align well with the schema definition and PR objectives.


202-233: LGTM!

Good test coverage for ListRunEventsResponse:

  • Validates the wrapper object structure
  • Correctly verifies that a plain array fails, ensuring the { events: [...] } wrapper is required

The tests confirm the API response shape change is properly enforced.

@bharathkumar39293 bharathkumar39293 marked this pull request as ready for review March 14, 2026 16:19
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 4 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

isCancelled: z.boolean(),
level: TaskEventLevel,
events: SpanEvents.optional(),
kind: z.string(),
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot Mar 14, 2026

Choose a reason for hiding this comment

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

📝 Info: ClickHouse getRunEvents hardcodes kind to 'UNSPECIFIED' and omits taskSlug

The ClickHouse #spanSummaryToRunPreparedEvent (apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts:1908-1925) hardcodes kind: "UNSPECIFIED" and does not include taskSlug. The RunEvent schema handles both: kind is z.string() so "UNSPECIFIED" is valid, and taskSlug is .optional(). The Prisma-based getRunEvents (apps/webapp/app/v3/eventRepository/eventRepository.server.ts:723-726) filters out kind === "UNSPECIFIED" events before returning, but the ClickHouse version doesn't—so ClickHouse-backed responses will have all events with kind: "UNSPECIFIED". This is pre-existing behavior and not caused by this PR, but it means the kind field is not very meaningful for ClickHouse-sourced events.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

listRunEvents(runId: string, requestOptions?: ZodFetchOptions) {
return zodfetch(
z.any(), // TODO: define a proper schema for this
ListRunEventsResponse,
Copy link
Contributor

Choose a reason for hiding this comment

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

🚩 Behavioral contract change: listRunEvents now transforms startTime from string to Date

Previously, listRunEvents used z.any() (packages/core/src/v3/apiClient/index.ts:705), meaning callers received the raw JSON from the server — with startTime as a 19-digit nanosecond string. Now it uses ListRunEventsResponse which parses startTime through NanosecondTimestampSchema, converting it to a Date object. This is a semantic change to a public API method.

The only current caller is in packages/cli-v3/src/dev/mcpServer.ts:210, which does JSON.stringify(result, null, 2)Date objects serialize to ISO strings via JSON.stringify, so the MCP output changes from a nanosecond string to an ISO string. This is arguably better, but it is a behavior change.

External consumers of the SDK's ApiClient.listRunEvents() will also see this change. The PR does export ListRunEventsResponseWithStringDates as a compatibility aid, but the ApiClient itself returns Date objects now. The changeset correctly marks this as a minor bump for @trigger.dev/core.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/core/src/v3/realtimeStreams/streamsWriterV2.ts (1)

226-226: Empty catch block could benefit from a brief comment.

The empty catch block is intentional (reader may already be released), but a brief comment explaining why the error is swallowed would improve clarity.

💡 Suggested improvement
 function safeReleaseLock(reader: ReadableStreamDefaultReader<any>) {
   try {
     reader.releaseLock();
-  } catch (error) { }
+  } catch {
+    // Ignore - lock may already be released
+  }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/v3/realtimeStreams/streamsWriterV2.ts` at line 226, Add a
brief explanatory comment to the empty catch block at the "catch (error) { }" in
packages/core/src/v3/realtimeStreams/streamsWriterV2.ts indicating the swallow
is intentional (e.g., the reader may already be released), and optionally note
that errors are non-fatal here or log them at trace/debug level if helpful; keep
the comment concise and colocated with that catch block so future readers
understand why the error is ignored.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli-v3/src/commands/deploy.ts`:
- Around line 1149-1157: The call to stream.readSession is using the wrong
flat/snake_case params (seq_num, wait); update the argument to the v0.22.5 shape
so readSession({ start: { from: { seqNum: 0 }, clamp: true }, stop: { waitSecs:
60 * 20 } }, { signal: abortController.signal }) is passed to stream.readSession
(keep the tryCatch wrapper and the second options object with
abortController.signal unchanged).

In `@packages/core/src/v3/realtimeStreams/streamsWriterV2.ts`:
- Line 138: Replace the invalid S2 SDK usages: in the streams writer options
object change the non-existent property maxQueuedBytes to maxInflightBytes (the
S2 SDK expects maxInflightBytes, default 5 MiB) and update any call sites that
used AppendRecord.make() to use the appropriate public factory like
AppendRecord.string() or AppendRecord.bytes() depending on whether you are
appending a string or binary payload (locate the call in the AppendRecord usage
in streamsWriterV2 and pick the matching factory); keep the seq_num rename as-is
if it matches S2 terminology but verify surrounding code still references
seq_num consistently (functions/classes to inspect: streamsWriterV2, the options
object where maxQueuedBytes was set, and the AppendRecord.* factory call site).

---

Nitpick comments:
In `@packages/core/src/v3/realtimeStreams/streamsWriterV2.ts`:
- Line 226: Add a brief explanatory comment to the empty catch block at the
"catch (error) { }" in packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
indicating the swallow is intentional (e.g., the reader may already be
released), and optionally note that errors are non-fatal here or log them at
trace/debug level if helpful; keep the comment concise and colocated with that
catch block so future readers understand why the error is ignored.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dd683633-f68f-449a-96b1-36dd7d974ee0

📥 Commits

Reviewing files that changed from the base of the PR and between 45c7318 and 3993730.

📒 Files selected for processing (6)
  • .changeset/define-runevent-schema.md
  • packages/cli-v3/src/commands/deploy.ts
  • packages/cli-v3/tsc_output.txt
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
📜 Review details
⏰ 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). (3)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{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

**/*.{ts,tsx}: Use task export syntax: export const myTask = task({ id: 'my-task', run: async (payload) => { ... } })
Use Run Engine 2.0 (@internal/run-engine) and redis-worker for all new work - avoid DEPRECATED zodworker (Graphile-worker wrapper)
Prisma 6.14.0 client and schema use PostgreSQL in internal-packages/database - import only from Prisma client

Files:

  • packages/cli-v3/src/commands/deploy.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
**/*.{ts,tsx,js,jsx}

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

Use function declarations instead of default exports

Files:

  • packages/cli-v3/src/commands/deploy.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries

Files:

  • packages/cli-v3/src/commands/deploy.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier before committing

Files:

  • packages/cli-v3/src/commands/deploy.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
packages/cli-v3/src/commands/**/*

📄 CodeRabbit inference engine (packages/cli-v3/CLAUDE.md)

CLI command definitions should be located in src/commands/

Files:

  • packages/cli-v3/src/commands/deploy.ts
packages/cli-v3/src/commands/deploy.ts

📄 CodeRabbit inference engine (packages/cli-v3/CLAUDE.md)

Implement deploy.ts command in src/commands/ for production deployment

Files:

  • packages/cli-v3/src/commands/deploy.ts
{packages,integrations}/**/*.{ts,tsx,js,json}

📄 CodeRabbit inference engine (CLAUDE.md)

When modifying public packages (packages/* or integrations/*), add a changeset using pnpm run changeset:add with default patch level for bug fixes and minor changes

Files:

  • packages/cli-v3/src/commands/deploy.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js}: Always import from @trigger.dev/sdk for Trigger.dev tasks - never use @trigger.dev/sdk/v3 or deprecated client.defineJob
Import subpaths only from @trigger.dev/core, never import from root
Add crumbs as you write code using // @crumbs comments or // #region @crumbs blocks for agentcrumbs debug tracing

Files:

  • packages/cli-v3/src/commands/deploy.ts
  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.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-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
**/*.{test,spec}.{ts,tsx}

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

Use vitest for all tests in the Trigger.dev repository

Files:

  • packages/core/src/v3/schemas/api-type.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 descriptive describe and it blocks
Tests should avoid mocks or stubs and use the helpers from @internal/testcontainers when Redis or Postgres are needed
Use vitest for running unit tests

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
packages/core/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (packages/core/CLAUDE.md)

Never import the root package (@trigger.dev/core). Always use subpath imports such as @trigger.dev/core/v3, @trigger.dev/core/v3/utils, @trigger.dev/core/logger, or @trigger.dev/core/schemas

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
**/*.test.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx,js}: Use vitest exclusively for testing - never mock anything, use testcontainers instead
Place test files next to source files with naming convention: SourceFile.ts -> SourceFile.test.ts

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use testcontainers for Redis/PostgreSQL testing instead of mocks with redisTest, postgresTest, or containerTest helpers from @internal/testcontainers

Files:

  • packages/core/src/v3/schemas/api-type.test.ts
🧠 Learnings (41)
📓 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} : Use `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation
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
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
📚 Learning: 2026-03-02T12:43:34.140Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/cli-v3/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:34.140Z
Learning: Applies to packages/cli-v3/src/commands/deploy.ts : Implement `deploy.ts` command in `src/commands/` for production deployment

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-03-02T12:43:34.140Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/cli-v3/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:34.140Z
Learning: Applies to packages/cli-v3/src/commands/promote.ts : Implement `promote.ts` command in `src/commands/` for deployment promotion

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-03-02T12:43:34.140Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/cli-v3/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:34.140Z
Learning: Applies to packages/cli-v3/src/deploy/archiveContext.ts : Archive deployment context files using `src/deploy/archiveContext.ts` to package files for deployment

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-03-02T12:43:34.140Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/cli-v3/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:34.140Z
Learning: Applies to packages/cli-v3/src/deploy/**/* : Deploy mode code should be located in `src/deploy/` and handles bundling, archiving, building Docker images, and pushing to registry

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-03-02T12:43:34.140Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/cli-v3/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:34.140Z
Learning: Applies to packages/cli-v3/src/deploy/buildImage.ts : Build Docker images using `src/deploy/buildImage.ts` for local Docker/Depot or remote builds

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-03-02T12:43:34.140Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/cli-v3/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:34.140Z
Learning: Applies to packages/cli-v3/src/commands/dev.ts : Implement `dev.ts` command in `src/commands/` for local development mode

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-03-02T12:43:34.140Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/cli-v3/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:34.140Z
Learning: Applies to packages/cli-v3/src/build/**/* : Build system in `src/build/` should use configuration from `trigger.config.ts` in user projects to determine bundling, build extensions, and output structure

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-02-06T19:53:46.849Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 2994
File: apps/webapp/app/presenters/v3/DeploymentListPresenter.server.ts:233-237
Timestamp: 2026-02-06T19:53:46.849Z
Learning: Vercel dashboard URLs for deployments use the format `https://vercel.com/${teamSlug}/${projectName}/${deploymentId}` where the deploymentId should NOT include the `dpl_` prefix. When constructing Vercel dashboard links from API deployment IDs (which include the `dpl_` prefix), the prefix must be stripped using `.replace(/^dpl_/, "")`.

Applied to files:

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

Applied to files:

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

Applied to files:

  • packages/cli-v3/src/commands/deploy.ts
📚 Learning: 2026-03-02T12:43:25.254Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: internal-packages/run-engine/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:25.254Z
Learning: Applies to internal-packages/run-engine/src/engine/tests/**/*.test.ts : Implement tests for RunEngine in `src/engine/tests/` using testcontainers for Redis and PostgreSQL containerization

Applied to files:

  • packages/core/src/v3/schemas/api-type.test.ts
📚 Learning: 2026-03-02T12:43:25.254Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: internal-packages/run-engine/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:25.254Z
Learning: Applies to internal-packages/run-engine/src/engine/systems/**/*.ts : Integrate OpenTelemetry tracer and meter instrumentation in RunEngine systems for observability

Applied to files:

  • packages/core/src/v3/schemas/api-type.test.ts
  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vitest for running unit tests

Applied to files:

  • packages/core/src/v3/schemas/api-type.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:

  • packages/core/src/v3/schemas/api-type.test.ts
📚 Learning: 2026-01-15T10:48:02.687Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T10:48:02.687Z
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:

  • packages/core/src/v3/schemas/api-type.test.ts
📚 Learning: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to **/*.{ts,tsx} : Use task export syntax: export const myTask = task({ id: 'my-task', run: async (payload) => { ... } })

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 `schemaTask()` from `trigger.dev/sdk/v3` with Zod schema for payload validation

Applied to files:

  • packages/core/src/v3/schemas/api.ts
  • .changeset/define-runevent-schema.md
📚 Learning: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to {packages,integrations}/**/*.{ts,tsx,js,json} : When modifying public packages (packages/* or integrations/*), add a changeset using pnpm run changeset:add with default patch level for bug fixes and minor changes

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} : Export tasks with unique IDs within the project to enable proper task discovery and 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} : 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} : Export every task, including subtasks

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to **/*.{ts,tsx} : Prisma 6.14.0 client and schema use PostgreSQL in internal-packages/database - import only from Prisma client

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to **/*.{ts,tsx} : Use Run Engine 2.0 (internal/run-engine) and redis-worker for all new work - avoid DEPRECATED zodworker (Graphile-worker wrapper)

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-13T13:37:49.544Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-13T13:37:49.544Z
Learning: Applies to **/*.{ts,tsx,js} : Always import from trigger.dev/sdk for Trigger.dev tasks - never use trigger.dev/sdk/v3 or deprecated client.defineJob

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-13T13:42:47.903Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3213
File: apps/webapp/app/routes/admin.api.v1.llm-models.$modelId.ts:40-43
Timestamp: 2026-03-13T13:42:47.903Z
Learning: In `apps/webapp/app/routes/admin.api.v1.llm-models.$modelId.ts` and `apps/webapp/app/routes/admin.api.v1.llm-models.ts`, the `startDate` field in `UpdateModelSchema` and `CreateModelSchema` intentionally uses `z.string().optional()` (or `.nullable().optional()`) without strict ISO datetime validation. Invalid date strings are rejected at the Prisma/DB layer. This is acceptable because these are admin-only API routes protected by Personal Access Token (PAT) authentication and are not user-facing.

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-01-28T14:15:15.011Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 2953
File: apps/webapp/app/components/runs/v3/SharedFilters.tsx:441-452
Timestamp: 2026-01-28T14:15:15.011Z
Learning: In apps/webapp/app/components/runs/v3/SharedFilters.tsx, the maxPeriodDays limit for date ranges should only check the from date (via dateRangeToDays(fromValue)) because it enforces data retention limits—how far back in history queries can reach. The to date is irrelevant for retention-based limits.

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2025-08-14T10:09:02.528Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2390
File: internal-packages/run-engine/src/engine/index.ts:466-467
Timestamp: 2025-08-14T10:09:02.528Z
Learning: In the triggerdotdev/trigger.dev codebase, it's acceptable to pass `string | undefined` types directly to Prisma operations (both create and update). The codebase consistently uses this pattern and the team is comfortable with how Prisma handles undefined values.

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2025-06-14T08:07:46.625Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 2175
File: apps/webapp/app/services/environmentMetricsRepository.server.ts:202-207
Timestamp: 2025-06-14T08:07:46.625Z
Learning: In apps/webapp/app/services/environmentMetricsRepository.server.ts, the ClickHouse methods (getTaskActivity, getCurrentRunningStats, getAverageDurations) intentionally do not filter by the `tasks` parameter at the ClickHouse level, even though the tasks parameter is accepted by the public methods. This is done on purpose as there is not much benefit from adding that filtering at the ClickHouse layer.

Applied to files:

  • packages/core/src/v3/schemas/api.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:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to {packages/core,apps/webapp}/**/*.{ts,tsx} : Use zod for validation in packages/core and apps/webapp

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: Target Run Engine V2 for all new code; the `engineVersion.server.ts` file determines V1 vs V2 for a given environment

Applied to files:

  • packages/core/src/v3/schemas/api.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:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: V1-only legacy code is located in `app/v3/marqs/`, `app/v3/legacyRunEngineWorker.server.ts`, `app/v3/services/triggerTaskV1.server.ts`, `app/v3/services/cancelTaskRunV1.server.ts`, `app/v3/authenticatedSocketConnection.server.ts`, and `app/v3/sharedSocketConnection.ts`

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: All run lifecycle operations (triggering, completing, cancelling, etc.) should be performed through the singleton run engine instance in `app/v3/runEngine.server.ts` via service calls

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:43:17.177Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: internal-packages/database/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:17.177Z
Learning: New code should always target Prisma RunEngineVersion V2 (run-engine + redis-worker), not V1 (legacy MarQS + Graphile)

Applied to files:

  • packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-02T12:42:56.114Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: apps/webapp/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:56.114Z
Learning: Applies to apps/webapp/app/v3/*Worker.server.ts : New background job workers should use `trigger.dev/redis-worker` (e.g., `commonWorker.server.ts`, `alertsWorker.server.ts`, `batchTriggerWorker.server.ts`), not zodworker or graphile-worker

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} : Subscribe to run updates using `runs.subscribeToRun()` for realtime monitoring of 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 `.withStreams()` to subscribe to realtime streams from task metadata in addition to run changes

Applied to files:

  • packages/core/src/v3/schemas/api.ts
  • packages/core/src/v3/realtimeStreams/streamsWriterV2.ts
📚 Learning: 2026-03-02T12:43:37.906Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/core/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:37.906Z
Learning: Exercise caution with changes to trigger.dev/core as they affect both the customer-facing SDK and server-side webapp - breaking changes can impact deployed user tasks and the platform simultaneously

Applied to files:

  • .changeset/define-runevent-schema.md
🔇 Additional comments (7)
packages/cli-v3/src/commands/deploy.ts (1)

1188-1194: Field access updated to match S2 SDK.

The change from record.seqNum to record.seq_num aligns with the S2 SDK API updates throughout this PR.

.changeset/define-runevent-schema.md (1)

1-5: Changeset looks good.

The minor version bump for @trigger.dev/core is appropriate since this PR adds new public schema exports (RunEvent, ListRunEventsResponse). As per coding guidelines: "add a changeset using pnpm run changeset:add with default patch level for bug fixes and minor changes".

packages/core/src/v3/schemas/api-type.test.ts (2)

143-266: Comprehensive test coverage for RunEvent schema.

The tests thoroughly cover:

  • Valid event parsing with date coercion
  • Various timestamp formats (ISO strings, nanoseconds, milliseconds, Date objects, bigints)
  • Optional/nullable fields (parentId, attemptNumber)
  • Invalid inputs and validation failures
  • The ListRunEventsResponseWithStringDates transform

Well-structured tests following vitest conventions.


268-299: Good test coverage for ListRunEventsResponse.

Tests verify the wrapped { events: [...] } structure and correctly reject plain arrays, ensuring consumers use the expected response shape.

packages/core/src/v3/schemas/api.ts (3)

1644-1668: Well-implemented timestamp coercion with validation.

The NanosecondTimestampSchema properly:

  • Accepts multiple input types (string, number, bigint, Date)
  • Handles 19-digit nanoseconds and 13-digit milliseconds
  • Validates the result with .refine() to reject invalid dates

This addresses the concerns from the previous review about validating transformed Date values.


1670-1686: RunEvent schema is well-structured.

The schema correctly handles:

  • Required fields (spanId, runId, message, etc.)
  • Optional/nullable fields (parentId, attemptNumber, taskSlug, events)
  • TaskEventStyle which provides sensible defaults for missing values

This tightens validation from the previous z.any() while remaining backward-compatible with existing API responses.


1698-1716: API response correctly matches the wrapped { events: [...] } structure.

The endpoint at apps/webapp/app/routes/api.v1.runs.$runId.events.ts returns json({ events: runEvents.map(...) }) on line 46-58, which aligns with the ListRunEventsResponse schema expecting { events: RunEvent[] }. The implementation is correct and will not cause validation failures.

Comment on lines 1149 to 1157
const [readSessionError, readSession] = await tryCatch(
stream.readSession(
{
start: { from: { seqNum: 0 }, clamp: true },
stop: { waitSecs: 60 * 20 }, // 20 minutes
seq_num: 0,
clamp: true,
wait: 60 * 20, // 20 minutes
},
{ signal: abortController.signal }
)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there's documentation or type definitions for S2 readSession in node_modules
fd -t f "index.d.ts" node_modules/@s2-dev 2>/dev/null | head -5 | xargs -I{} grep -l "readSession" {} 2>/dev/null || echo "S2 types not found in node_modules"

Repository: triggerdotdev/trigger.dev

Length of output: 51


🏁 Script executed:

# Find deploy.ts and read the context around lines 1149-1157
fd -t f "deploy.ts" packages/cli-v3/src/commands/ | head -1 | xargs -I{} sh -c 'echo "File: {}" && wc -l {}'

Repository: triggerdotdev/trigger.dev

Length of output: 157


🏁 Script executed:

# Read lines around 1149-1157 in deploy.ts with context
sed -n '1140,1170p' packages/cli-v3/src/commands/deploy.ts

Repository: triggerdotdev/trigger.dev

Length of output: 974


🏁 Script executed:

# Look for streamsWriterV2.ts to compare API changes
fd -t f "streamsWriterV2.ts" --type f

Repository: triggerdotdev/trigger.dev

Length of output: 124


🏁 Script executed:

# Check package.json for `@s2-dev/streamstore` version
fd -t f "package.json" packages/cli-v3 | xargs grep -l "@s2-dev" | head -1 | xargs cat | grep -A 5 "@s2-dev"

Repository: triggerdotdev/trigger.dev

Length of output: 303


🏁 Script executed:

# Search for any references to the old readSession API format
rg "start.*from.*seqNum|stop.*waitSecs" --type ts --type tsx

Repository: triggerdotdev/trigger.dev

Length of output: 96


🏁 Script executed:

# Read streamsWriterV2.ts to see if there are similar readSession API calls
cat -n packages/core/src/v3/realtimeStreams/streamsWriterV2.ts | grep -A 10 -B 2 "readSession"

Repository: triggerdotdev/trigger.dev

Length of output: 51


🏁 Script executed:

# Search for old seqNum/waitSecs format without --type flag
rg "seqNum|waitSecs" packages/cli-v3/src/ packages/core/src/ -A 3 -B 3 | head -50

Repository: triggerdotdev/trigger.dev

Length of output: 3040


🏁 Script executed:

# Check if there's any git history or comments explaining the API change
git log --oneline -n 20 -- packages/cli-v3/src/commands/deploy.ts 2>/dev/null | head -10

Repository: triggerdotdev/trigger.dev

Length of output: 163


🏁 Script executed:

# Search for any S2 API documentation or examples in the codebase
rg "readSession" packages/ -A 5 -B 2 | head -80

Repository: triggerdotdev/trigger.dev

Length of output: 1920


🏁 Script executed:

# Look at streamsWriterV2.ts more carefully for any readSession usage
cat packages/core/src/v3/realtimeStreams/streamsWriterV2.ts | head -150

Repository: triggerdotdev/trigger.dev

Length of output: 4999


🏁 Script executed:

# Search for S2 type imports or interfaces
rg "S2|readSession" packages/cli-v3/src/commands/deploy.ts -B 5 | head -60

Repository: triggerdotdev/trigger.dev

Length of output: 1022


🏁 Script executed:

# Look for any git diff or changes related to readSession
git diff HEAD~5 HEAD -- packages/cli-v3/src/commands/deploy.ts 2>/dev/null | grep -A 5 -B 5 "readSession" | head -50 || echo "Git diff not available"

Repository: triggerdotdev/trigger.dev

Length of output: 51


🌐 Web query:

@s2-dev/streamstore v0.22.5 readSession API parameters documentation

💡 Result:

In @s2-dev/streamstore v0.22.5, the TypeScript signature is:
stream.readSession(input?: ReadInput, options?: S2RequestOptions & { as?: "string" | "bytes" }): Promise<ReadSession<...>>.[1]

readSession(input) parameters (ReadInput)

ReadInput is:[2]

  • start?: ReadStart

    • from?: ReadFrom (choose one)
      • { seqNum: number } – start at (or after) this sequence number[2]
      • { timestamp: number | Date } – start at (or after) this timestamp[2]
      • { tailOffset: number } – start N records before the current tail[2]
    • clamp?: boolean – if the requested start is beyond the tail, start from the tail instead[2]
  • stop?: ReadStop

    • limits?: ReadLimits
      • count?: number – max records to return[2]
      • bytes?: number – max bytes to return[2]
    • untilTimestamp?: number | Date – stop when records reach this timestamp (exclusive)[2]
    • waitSecs?: number – stop if no new records arrive for this many seconds (floored to an integer when sent)[2]
  • ignoreCommandRecords?: boolean – omit command records from results[2]

readSession(options) parameters

  • as?: "string" | "bytes" – if "bytes", record bodies/headers are decoded to Uint8Array[1]
  • Plus standard S2RequestOptions (request-level options used across SDK calls)[1]

Sources: v0.22.5 type declarations for S2Stream.readSession and ReadInput/related types.[1][2]


🏁 Script executed:

# Double-check by looking for any type definitions or imports of ReadInput in the repo
rg "ReadInput|ReadStart|ReadStop" packages/ -A 2 | head -40

Repository: triggerdotdev/trigger.dev

Length of output: 51


🏁 Script executed:

# Check if there's any S2 type definition file or wrapper
fd -t f "index.d.ts" packages/ | xargs grep -l "readSession" 2>/dev/null || echo "No local S2 types found"

Repository: triggerdotdev/trigger.dev

Length of output: 92


🏁 Script executed:

# Verify the exact line in deploy.ts to ensure we have correct context
sed -n '1145,1165p' packages/cli-v3/src/commands/deploy.ts

Repository: triggerdotdev/trigger.dev

Length of output: 798


Fix invalid S2 readSession API parameters for v0.22.5.

The readSession call uses incorrect parameter names and structure. The @s2-dev/streamstore v0.22.5 API expects:

{
  start: { from: { seqNum: 0 }, clamp: true },
  stop: { waitSecs: 60 * 20 }
}

Not the flat structure with snake_case names currently used (seq_num, wait). This will fail at runtime.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli-v3/src/commands/deploy.ts` around lines 1149 - 1157, The call to
stream.readSession is using the wrong flat/snake_case params (seq_num, wait);
update the argument to the v0.22.5 shape so readSession({ start: { from: {
seqNum: 0 }, clamp: true }, stop: { waitSecs: 60 * 20 } }, { signal:
abortController.signal }) is passed to stream.readSession (keep the tryCatch
wrapper and the second options object with abortController.signal unchanged).

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

View 6 additional findings in Devin Review.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant