Skip to content

Conversation

@ericallam
Copy link
Member

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

⚠️ No Changeset found

Latest commit: 8fdba72

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

This PR includes no changesets

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

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

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Warning

Rate limit exceeded

@ericallam has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 52 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a9ba909 and 8fdba72.

⛔ Files ignored due to path filters (1)
  • references/realtime-streams/src/app/actions.ts is excluded by !references/**
📒 Files selected for processing (11)
  • apps/webapp/app/env.server.ts (1 hunks)
  • apps/webapp/app/routes/api.v1.tasks.$taskId.batch.ts (3 hunks)
  • apps/webapp/app/routes/api.v1.tasks.$taskId.trigger.ts (2 hunks)
  • apps/webapp/app/routes/api.v1.tasks.batch.ts (3 hunks)
  • apps/webapp/app/routes/api.v2.tasks.batch.ts (3 hunks)
  • apps/webapp/app/runEngine/services/batchTrigger.server.ts (2 hunks)
  • apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1 hunks)
  • apps/webapp/app/v3/services/batchTriggerV3.server.ts (2 hunks)
  • apps/webapp/app/v3/services/replayTaskRun.server.ts (2 hunks)
  • apps/webapp/app/v3/services/triggerTask.server.ts (1 hunks)
  • packages/core/src/v3/apiClient/index.ts (1 hunks)

Walkthrough

This pull request introduces configurable realtime streams versioning throughout the application. A new environment variable REALTIME_STREAMS_DEFAULT_VERSION is added to set a default version ("v1" or "v2"). Multiple API routes now accept and extract a new request header "x-trigger-realtime-streams-version". A utility function determineRealtimeStreamsVersion is introduced to resolve the appropriate version based on request input, environment defaults, and S2 infrastructure availability. The realtimeStreamsVersion parameter is threaded through batch trigger services and individual task trigger services. The API client logic is updated to determine stream version selection and set the corresponding response header.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • determineRealtimeStreamsVersion function: Review the conditional logic for S2 configuration checks and default fallback behavior in v1StreamsGlobal.server.ts
  • Type consistency: Verify that the "v1" | "v2" union type is consistently applied across TriggerTaskServiceOptions, BatchTriggerTaskServiceOptions, and all service call sites
  • Parameter propagation chain: Trace the realtimeStreamsVersion parameter flow from API routes → batch trigger services → task trigger services to ensure it is correctly passed through all layers
  • API client version selection logic: Review the streamFlag conditional logic in apiClient/index.ts that determines version based on multiple environment variables and sets the corresponding header

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is completely empty, missing all required template sections including testing, changelog, issue reference, and checklist items. Fill in the required template sections: add the issue number (Closes #), complete the checklist, describe testing steps, add a changelog entry, and include screenshots if applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: making v2 streams the default version when supported, which is the core objective reflected across multiple file modifications.

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

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1)

63-77: Consider logging unexpected stream version values.

The function correctly implements the version resolution logic: defaulting to the environment configuration when no version is specified, and returning "v2" only when explicitly requested and S2 infrastructure is available. However, if an unexpected value (e.g., "v3", "invalid") is passed, it silently falls back to "v1". While this provides forward compatibility, consider adding a debug log when an unexpected non-empty value is passed to help diagnose configuration issues.

Example:

 export function determineRealtimeStreamsVersion(streamVersion?: string): "v1" | "v2" {
   if (!streamVersion) {
     return env.REALTIME_STREAMS_DEFAULT_VERSION;
   }

   if (
     streamVersion === "v2" &&
     env.REALTIME_STREAMS_S2_BASIN &&
     env.REALTIME_STREAMS_S2_ACCESS_TOKEN
   ) {
     return "v2";
   }

+  if (streamVersion !== "v1") {
+    logger.debug("Unexpected realtime streams version, falling back to v1", {
+      requestedVersion: streamVersion
+    });
+  }
+
   return "v1";
 }
apps/webapp/app/routes/api.v2.tasks.batch.ts (1)

70-79: Consider adding realtimeStreamsVersion to debug logging.

The newly extracted realtimeStreamsVersion header is not included in the debug log statement, while other headers (including batchProcessingStrategy and requestIdempotencyKey) are logged. For consistency and better observability, consider adding it.

Apply this diff:

 logger.debug("Batch trigger request", {
   triggerVersion,
   spanParentAsLink,
   isFromWorker,
   triggerClient,
   traceparent,
   tracestate,
   batchProcessingStrategy,
   requestIdempotencyKey,
+  realtimeStreamsVersion,
 });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8cec3b7 and a9ba909.

⛔ Files ignored due to path filters (1)
  • references/realtime-streams/src/app/actions.ts is excluded by !references/**
📒 Files selected for processing (10)
  • apps/webapp/app/env.server.ts (1 hunks)
  • apps/webapp/app/routes/api.v1.tasks.$taskId.batch.ts (3 hunks)
  • apps/webapp/app/routes/api.v1.tasks.$taskId.trigger.ts (2 hunks)
  • apps/webapp/app/routes/api.v1.tasks.batch.ts (3 hunks)
  • apps/webapp/app/routes/api.v2.tasks.batch.ts (3 hunks)
  • apps/webapp/app/runEngine/services/batchTrigger.server.ts (2 hunks)
  • apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1 hunks)
  • apps/webapp/app/v3/services/batchTriggerV3.server.ts (2 hunks)
  • apps/webapp/app/v3/services/triggerTask.server.ts (1 hunks)
  • packages/core/src/v3/apiClient/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 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:

  • apps/webapp/app/v3/services/triggerTask.server.ts
📚 Learning: 2025-08-14T18:35:44.370Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2390
File: apps/webapp/app/env.server.ts:764-765
Timestamp: 2025-08-14T18:35:44.370Z
Learning: The BoolEnv helper in apps/webapp/app/utils/boolEnv.ts uses z.preprocess with inconsistent default value types across the codebase - some usages pass boolean defaults (correct) while others pass string defaults (incorrect), leading to type confusion. The helper should enforce boolean-only defaults or have clearer documentation.

Applied to files:

  • apps/webapp/app/env.server.ts
🧬 Code graph analysis (8)
apps/webapp/app/v3/services/batchTriggerV3.server.ts (1)
apps/webapp/app/runEngine/services/batchTrigger.server.ts (1)
  • options (342-348)
apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1)
apps/webapp/app/env.server.ts (1)
  • env (1246-1246)
apps/webapp/app/routes/api.v2.tasks.batch.ts (1)
apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1)
  • determineRealtimeStreamsVersion (63-77)
packages/core/src/v3/apiClient/index.ts (1)
packages/core/src/v3/utils/getEnv.ts (1)
  • getEnvVar (11-13)
apps/webapp/app/routes/api.v1.tasks.$taskId.trigger.ts (1)
apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1)
  • determineRealtimeStreamsVersion (63-77)
apps/webapp/app/runEngine/services/batchTrigger.server.ts (1)
apps/webapp/app/v3/services/batchTriggerV3.server.ts (1)
  • options (896-902)
apps/webapp/app/routes/api.v1.tasks.batch.ts (1)
apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1)
  • determineRealtimeStreamsVersion (63-77)
apps/webapp/app/routes/api.v1.tasks.$taskId.batch.ts (1)
apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts (1)
  • determineRealtimeStreamsVersion (63-77)
⏰ 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 (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 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 (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 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 (5, 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 (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (12)
apps/webapp/app/v3/services/triggerTask.server.ts (1)

36-36: LGTM: Type restriction improves safety.

Restricting realtimeStreamsVersion from string to "v1" | "v2" provides better type safety and ensures only valid versions are accepted. All call sites properly use determineRealtimeStreamsVersion() which returns this union type.

apps/webapp/app/env.server.ts (1)

1239-1239: LGTM: Safe default for realtime streams version.

The new environment variable REALTIME_STREAMS_DEFAULT_VERSION with enum ["v1", "v2"] and default "v1" provides a sensible fallback. This ensures existing deployments without S2 configuration will continue using v1 streams.

apps/webapp/app/routes/api.v1.tasks.batch.ts (1)

112-114: LGTM: Consistent header normalization.

The route correctly extracts the x-trigger-realtime-streams-version header and normalizes it through determineRealtimeStreamsVersion() before passing to the service. This ensures proper version resolution based on both client preference and server configuration.

apps/webapp/app/routes/api.v1.tasks.$taskId.trigger.ts (1)

130-132: LGTM: Proper version normalization.

The implementation correctly normalizes the realtime streams version through determineRealtimeStreamsVersion() before passing to TriggerTaskService, ensuring consistent behavior across the application.

apps/webapp/app/v3/services/batchTriggerV3.server.ts (1)

59-59: LGTM: Proper option propagation.

The new realtimeStreamsVersion?: "v1" | "v2" option is correctly added to BatchTriggerTaskServiceOptions and properly forwarded to TriggerTaskService.call() at line 855, maintaining consistency across the batch triggering flow.

apps/webapp/app/routes/api.v1.tasks.$taskId.batch.ts (1)

105-105: LGTM: Consistent implementation.

The route follows the established pattern of normalizing the realtime streams version through determineRealtimeStreamsVersion() before passing to the service, ensuring proper fallback behavior.

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

1216-1228: Consolidate to single environment variable or document backwards compatibility requirement.

The client-defaulting-to-v2 while server-defaults-to-v1 pattern is intentional and correct—the server's determineRealtimeStreamsVersion() validates S2 availability and falls back to v1 gracefully. However, the dual environment variable check needs clarification.

Both TRIGGER_V2_REALTIME_STREAMS and TRIGGER_REALTIME_STREAMS_V2 appear only in this single location (lines 1220–1223) and nowhere else in the codebase. They're not defined in env.server.ts, not documented, and not checked by the server (which uses REALTIME_STREAMS_S2_BASIN and REALTIME_STREAMS_S2_ACCESS_TOKEN instead). The inconsistent naming suggests either intentional backwards compatibility with two naming schemes or incomplete refactoring. If backwards compatibility is needed, document it; otherwise, consolidate to one environment variable name.

apps/webapp/app/runEngine/services/batchTrigger.server.ts (2)

50-50: LGTM!

The addition of the realtimeStreamsVersion optional field to BatchTriggerTaskServiceOptions is correctly typed and appropriately optional. This aligns with the PR objective to support configurable realtime streams versioning.


712-712: LGTM!

The realtimeStreamsVersion is correctly propagated from the batch options to individual task triggers. The optional chaining ensures safe handling when the option is not provided.

apps/webapp/app/routes/api.v2.tasks.batch.ts (3)

21-21: LGTM!

The import of determineRealtimeStreamsVersion is correct and the function is properly utilized below.


63-63: LGTM!

The header extraction for x-trigger-realtime-streams-version follows the established pattern and naming convention.


124-126: LGTM!

The call to determineRealtimeStreamsVersion correctly normalizes the streams version based on the header value, environment configuration, and infrastructure availability. The result is properly passed to the service.

@ericallam ericallam merged commit 6137338 into main Nov 13, 2025
31 checks passed
@ericallam ericallam deleted the ea-branch-99 branch November 13, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants