Title: bug: getRunIdForOptions function is duplicated, contains inconsistent fallback behavior · Issue #2852 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: bug: getRunIdForOptions function is duplicated, contains inconsistent fallback behavior · Issue #2852 · triggerdotdev/trigger.dev
X Title: bug: getRunIdForOptions function is duplicated, contains inconsistent fallback behavior · Issue #2852 · triggerdotdev/trigger.dev
Description: Provide environment information System: OS: macOS 15.7.3 CPU: (16) arm64 Apple M4 Max Memory: 1.99 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 22.16.0 - Yarn: 1.22.22 npm: 10.9.2 pnpm: 10.26.2 Watchman: 2026.01.05.00 Describe the...
Open Graph Description: Provide environment information System: OS: macOS 15.7.3 CPU: (16) arm64 Apple M4 Max Memory: 1.99 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 22.16.0 - Yarn: 1.22.22 npm: 10.9.2 pnpm: 10.2...
X Description: Provide environment information System: OS: macOS 15.7.3 CPU: (16) arm64 Apple M4 Max Memory: 1.99 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 22.16.0 - Yarn: 1.22.22 npm: 10.9.2 pnpm: 10.2...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/2852
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: getRunIdForOptions function is duplicated, contains inconsistent fallback behavior","articleBody":"### Provide environment information\n\nSystem:\n OS: macOS 15.7.3\n CPU: (16) arm64 Apple M4 Max\n Memory: 1.99 GB / 64.00 GB\n Shell: 5.9 - /bin/zsh\n\n Binaries:\n Node: 22.16.0 - \n Yarn: 1.22.22 \n npm: 10.9.2 \n pnpm: 10.26.2 \n Watchman: 2026.01.05.00 \n\n### Describe the bug\n\nThe `getRunIdForOptions` function is duplicated in two locations with inconsistent fallback behavior. The SDK version (`packages/trigger-sdk/src/v3/streams.ts`) lacks fallback logic that exists in the core implementation (`packages/core/src/v3/realtimeStreams/manager.ts`).\n\nWhen calling `streams.pipe(\"key\", stream, { target: \"root\" })` from a root task (a task not triggered by another task), the SDK throws an error instead of falling back to the current run ID. The semantic meaning of target: \"root\" is \"send to the root of this task tree\" - if the current task IS the root, it should behave the same as target: \"self\".\n\n\n### Reproduction repo\n\nThis can be reproduced in any Trigger.dev project using the SDK's streams.pipe() API with target: \"root\" from a directly-triggered task.\n\n### To reproduce\n\n```typescript\nimport { streams, task } from \"@trigger.dev/sdk\";\n\n // This task is triggered directly (not a child of another task)\n export const rootTask = task({\n id: \"root-task\",\n run: async (payload) =\u003e {\n const myStream = createSomeAsyncGenerator();\n\n // This will throw an error even though it should work\n const { waitUntilComplete } = streams.pipe(\"output\", myStream, {\n target: \"root\" // Fails because rootTaskRunId is undefined for root tasks\n });\n\n await waitUntilComplete();\n },\n });\n```\n\n **Steps:**\n 1. Create a task that is triggered directly (not as a child of another task)\n 2. Call streams.pipe() with { target: \"root\" }\n 3. Observe the error is thrown\n\n\n### Additional information\n\n**Root Cause:** Two `getRunIdForOptions` functions exist with different behavior:\n\n | File | Fallback for `\"root\"`/`\"parent\"`? |\n |------|----------------------------------|\n | `packages/trigger-sdk/src/v3/streams.ts:665-683` | ❌ No |\n | `packages/core/src/v3/realtimeStreams/manager.ts:141-159` | ✅ Yes |\n\n **Why the core fallback is unreachable:** The SDK resolves targets to string IDs FIRST, then passes them to the core. By the time `StandardRealtimeStreamsManager.pipe()` is called, it receives a string ID (or an error was already thrown), so its fallback logic is dead code for SDK callers.\n\n **Evidence the fallback is intended:**\n - Documentation (`docs/tasks/streams.mdx:374,399`) shows `target: \"root\"` as valid usage\n - Internal API (`packages/core/src/v3/runMetadata/manager.ts:330-333`) passes semantic targets directly and relies on the fallback\n\n **Origin:** Both functions introduced in same commit (`536d9fa21` - \"feat(realtime): Realtime streams v2 #2632\"). Inconsistency was present from creation.\n\n **Affected functions:** `streams.pipe()`, `streams.append()`, `streams.writer()` - all use the same `getRunIdForOptions` in `streams.ts`","author":{"url":"https://github.com/robraux","@type":"Person","name":"robraux"},"datePublished":"2026-01-08T15:11:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2852/trigger.dev/issues/2852"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:29e1f2ad-a3d7-5718-d1d1-e20ed0cffc93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E68:281ABF:1AA24C2:243CCB7:6964BBCC |
| html-safe-nonce | b4ec8ac206c12be0bb7cfb147ca45adc4ac74d4e5e3205092ea6f38220c8a908 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTY4OjI4MUFCRjoxQUEyNEMyOjI0M0NDQjc6Njk2NEJCQ0MiLCJ2aXNpdG9yX2lkIjoiOTE0NDQ5MDYzOTE5OTg3ODA5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 73a0a6e418bf6dbb640506ce3263191a119847af0eb050bc5a6196cc07778864 |
| hovercard-subject-tag | issue:3793287237 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/triggerdotdev/trigger.dev/2852/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2900a67752c2462230d9ff3d70c1f8e5c117d3a3d956df704e4bfe03d529ad6e/triggerdotdev/trigger.dev/issues/2852 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2900a67752c2462230d9ff3d70c1f8e5c117d3a3d956df704e4bfe03d529ad6e/triggerdotdev/trigger.dev/issues/2852 |
| og:image:alt | Provide environment information System: OS: macOS 15.7.3 CPU: (16) arm64 Apple M4 Max Memory: 1.99 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 22.16.0 - Yarn: 1.22.22 npm: 10.9.2 pnpm: 10.2... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | robraux |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9917306ebdf5f9f30d13ede7b74f08a45b5f12b401ce3e4bfabd895ea0ca0ada |
| turbo-cache-control | no-preview |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 020ceddb26807bba62dcfb410905847d63243ff5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width