fix(cli): upgrade import-in-the-middle to v3.0.0#3207
Conversation
Fixes the `importAssertions` deprecation warning on Node.js v21+, v20.10.0+, and v18.19.0+. This resolves the error that occurred when using certain OpenTelemetry instrumentations like UndiciInstrumentation, HttpInstrumentation, and AwsInstrumentation. Closes #3205 Co-authored-by: Eric Allam <ericallam@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 92b158e The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe pull request upgrades the "import-in-the-middle" dependency from version 1.11.0 to 3.0.0 across the codebase. The changes include updating the package dependency declaration in packages/cli-v3/package.json, updating the corresponding version references in e2e test fixtures, and adding a changeset entry documenting the upgrade. The upgrade addresses importAssertions deprecation warnings on Node.js v21+, v20.10.0+, and v18.19.0+. Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| "has-flag": "^5.0.1", | ||
| "ignore": "^7.0.5", | ||
| "import-in-the-middle": "1.11.0", | ||
| "import-in-the-middle": "3.0.0", |
There was a problem hiding this comment.
🚩 Dual versions of import-in-the-middle at runtime (3.0.0 and 1.11.0)
The pnpm-lock.yaml shows that @opentelemetry/instrumentation@0.203.0 still resolves its own import-in-the-middle to 1.11.0, while the CLI's direct dependency is now 3.0.0. At runtime in customer containers, loader.ts:2-4 creates the hook message channel using v3.0.0's createAddHookMessageChannel and registers import-in-the-middle/hook.mjs from v3.0.0. Meanwhile, @opentelemetry/instrumentation uses its own v1.11.0 to call addHook for module interception. These two versions need compatible message channel protocols for the hooks to work. The v3.0.0 release was primarily about replacing importAssertions with importAttributes (as stated in the changeset), and the Hook/addHook API appears to be preserved. However, if the internal IPC protocol between hook.mjs and the Hook class changed across major versions, this could silently break OpenTelemetry instrumentation hooks. Worth verifying that the e2e tests pass end-to-end with instrumented packages (the otel-telemetry-loader fixture tests this).
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/package.json`:
- Line 117: The loader currently awaits the property reference
waitForAllMessagesAcknowledged instead of calling it, so update
packages/cli-v3/src/entryPoints/loader.ts to call
waitForAllMessagesAcknowledged() where it’s awaited (after importing from
import-in-the-middle) to ensure the ACK barrier runs; replace any await
waitForAllMessagesAcknowledged with await waitForAllMessagesAcknowledged() and
keep the import/usage of import-in-the-middle unchanged so the hook handshake
completes before continuing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 16cc60cf-9e54-4f9f-b4ba-9ca0200c29e0
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
.changeset/upgrade-import-in-the-middle.mdpackages/cli-v3/e2e/fixtures.tspackages/cli-v3/package.json
📜 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). (25)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: sdk-compat / Deno Runtime
- GitHub Check: sdk-compat / Node.js 20.20 (ubuntu-latest)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: sdk-compat / Bun Runtime
- GitHub Check: typecheck / typecheck
- GitHub Check: sdk-compat / Node.js 22.12 (ubuntu-latest)
- GitHub Check: sdk-compat / Cloudflare Workers
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}
📄 CodeRabbit inference engine (AGENTS.md)
Format code using Prettier before committing
Files:
packages/cli-v3/package.jsonpackages/cli-v3/e2e/fixtures.ts
**/*.{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}: In TypeScript SDK usage, always import from@trigger.dev/sdk, never from@trigger.dev/sdk/v3or use deprecated client.defineJob
Import from@trigger.dev/coresubpaths only, never from the root
Use the Run Engine 2.0 (@internal/run-engine) and redis-worker for all new work, not legacy V1 MarQS queue or deprecated V1 functions
Files:
packages/cli-v3/e2e/fixtures.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Files:
packages/cli-v3/e2e/fixtures.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/e2e/fixtures.ts
🧠 Learnings (16)
📓 Common learnings
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/trigger-sdk/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:48.124Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx,js,jsx} : Always import from `trigger.dev/sdk`. Never use `trigger.dev/sdk/v3` (deprecated path alias)
📚 Learning: 2026-03-02T12:42:41.110Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:41.110Z
Learning: Applies to packages/**/*.{ts,tsx,js},integrations/**/*.{ts,tsx,js} : When modifying public packages (packages/* or integrations/*), add a changeset via pnpm run changeset:add
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 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/e2e/fixtures.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `trigger.dev/sdk/v3` for all imports in Trigger.dev tasks
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Configure build process in trigger.config.ts using `build` object with external packages, extensions, and JSX settings
Applied to files:
packages/cli-v3/e2e/fixtures.ts
📚 Learning: 2026-03-02T12:43:48.124Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: packages/trigger-sdk/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:48.124Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx,js,jsx} : Always import from `trigger.dev/sdk`. Never use `trigger.dev/sdk/v3` (deprecated path alias)
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : When importing from `trigger.dev/core` in the webapp, use subpath exports from the package.json instead of importing from the root path
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Use build extensions in trigger.config.ts (additionalFiles, additionalPackages, aptGet, prismaExtension, etc.) to customize the build
Applied to files:
packages/cli-v3/e2e/fixtures.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `tasks.trigger()` with type-only imports to trigger tasks from backend code without importing the task implementation
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 Learning: 2026-03-02T12:42:41.110Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:41.110Z
Learning: Applies to **/*.{ts,tsx} : Import from trigger.dev/core subpaths only, never from the root
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 Learning: 2026-03-02T12:42:41.110Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-02T12:42:41.110Z
Learning: Applies to **/*.{ts,tsx} : In TypeScript SDK usage, always import from trigger.dev/sdk, never from trigger.dev/sdk/v3 or use deprecated client.defineJob
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 Learning: 2026-03-02T12:43:02.539Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2026-03-02T12:43:02.539Z
Learning: Applies to docs/**/*.mdx : Always import from `trigger.dev/sdk` in code examples (never from `trigger.dev/sdk/v3`)
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 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: Applies to packages/core/**/*.{ts,tsx,js,jsx} : 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
Applied to files:
packages/cli-v3/e2e/fixtures.ts.changeset/upgrade-import-in-the-middle.md
📚 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/**/* : Bundle worker code using the build system in `src/build/` based on configuration from `trigger.config.ts`
Applied to files:
packages/cli-v3/e2e/fixtures.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:
.changeset/upgrade-import-in-the-middle.md
📚 Learning: 2025-10-08T11:48:12.327Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2593
File: packages/core/src/v3/workers/warmStartClient.ts:168-170
Timestamp: 2025-10-08T11:48:12.327Z
Learning: The trigger.dev runners execute only in Node 21 and 22 environments, so modern Node.js APIs like AbortSignal.any (introduced in v20.3.0) are supported.
Applied to files:
.changeset/upgrade-import-in-the-middle.md
🔇 Additional comments (2)
.changeset/upgrade-import-in-the-middle.md (1)
1-7: Good release-note coverage.This explains both the dependency bump and the runtime symptom it addresses, which should make the patch release easier to understand.
packages/cli-v3/e2e/fixtures.ts (1)
52-52: Fixture expectations stay aligned with the pinned dependency.Updating these manifest matchers in the same PR keeps the e2e assertions consistent with
packages/cli-v3/package.json.Also applies to: 85-85, 117-117, 148-148, 181-181
| "has-flag": "^5.0.1", | ||
| "ignore": "^7.0.5", | ||
| "import-in-the-middle": "1.11.0", | ||
| "import-in-the-middle": "3.0.0", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify the current loader integration still awaits the symbol instead of invoking it.
sed -n '1,120p' packages/cli-v3/src/entryPoints/loader.ts
rg -n "waitForAllMessagesAcknowledged" packages/cli-v3/src/entryPoints/loader.tsRepository: triggerdotdev/trigger.dev
Length of output: 1009
Call waitForAllMessagesAcknowledged() as a function in the loader.
The upgrade to import-in-the-middle v3.0.0 on line 117 of package.json requires updating the loader integration. In packages/cli-v3/src/entryPoints/loader.ts line 26, waitForAllMessagesAcknowledged is currently awaited as a property reference, but the v3.0.0 API exposes it as a function. This causes the ACK barrier to be skipped, allowing execution to continue before the hook handshake completes.
Fix in packages/cli-v3/src/entryPoints/loader.ts
- await waitForAllMessagesAcknowledged;
+ await waitForAllMessagesAcknowledged();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/cli-v3/package.json` at line 117, The loader currently awaits the
property reference waitForAllMessagesAcknowledged instead of calling it, so
update packages/cli-v3/src/entryPoints/loader.ts to call
waitForAllMessagesAcknowledged() where it’s awaited (after importing from
import-in-the-middle) to ensure the ACK barrier runs; replace any await
waitForAllMessagesAcknowledged with await waitForAllMessagesAcknowledged() and
keep the import/usage of import-in-the-middle unchanged so the hook handshake
completes before continuing.
Summary
import-in-the-middlefrom v1.11.0 to v3.0.0importAssertionsdeprecation warning on Node.js v21+, v20.10.0+, v18.19.0+Closes #3205
Test Plan
Generated with Claude Code