fix(node): Bootstrap Mastra observability under ESM - #24177
Open
mydea wants to merge 2 commits into
Open
Conversation
Contributor
size-limit report 📦
|
…e dependency
`@mastra/core` declares `engines.node >= 22.13`, so having it in the
node-integration-tests `devDependencies` broke `yarn install` on the
Node 20.19 CI matrix with "The engine \"node\" is incompatible with this module".
Move `@mastra/core` and `@mastra/observability` into per-suite
`additionalDependencies` on the Mastra runner instead. Those are only
installed when the suite runs, and the suite is already gated behind
`conditionalTest({ min: 22 })`, so Node 20 never touches them.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mydea
force-pushed
the
fix/mastra-deps-node-engine
branch
from
September 7, 2026 14:33
a9e0103 to
d28f3f3
Compare
mydea
marked this pull request as ready for review
September 7, 2026 14:45
mydea
requested review from
andreiborza and
isaacs
and removed request for
a team
September 7, 2026 14:45
RulaKhaled
approved these changes
Sep 7, 2026
RulaKhaled
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! thank you for fixing this
timfish
approved these changes
Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Mastra integration failed to auto-bootstrap
@mastra/observabilityunder ESM when the app configured no observability of its own.loadMastraObservability()anchored module resolution onprocess.cwd()and the CJSrequire.cache, but an ESM-loaded@mastra/corenever lands in that cache, leaving cwd as the only anchor. When the app's dependencies don't live under cwd — a serverless/monorepo layout, or concretely the per-suite temp install the integration tests use — resolution failed silently: no exporter was attached and nogen_aispans were produced, so the ESMscenario-autotest timed out.The runtime injection hook already receives the resolved
file:URL of every module it instruments and was throwing it away. We now record it on__SENTRY_ORCHESTRION__.runtimeFilesand let the Mastra integration anchor@mastra/observabilityresolution on the app's actual@mastra/corefile. This works under both ESM and CJS and no longer depends on cwd; the CJS-cache and cwd lookups remain as fallbacks.Decisions:
@mastra/core, not@mastra/observability. The latter is never loaded in the failing case — that is precisely why the SDK has to bootstrap it — so there is nothing to hook there.@mastra/coreis always loaded when the integration runs.This also moves
@mastra/coreand@mastra/observabilityout of thenode-integration-testsworkspacedevDependenciesinto the runner's per-suiteadditionalDependencies.@mastra/coredeclaresengines.node >= 22.13, so a workspacedevDependencybrokeyarn installon the Node 20.19 CI matrix even though the suite is gated behindconditionalTest({ min: 22 }). Installing them into the test's temp dir at run time means Node 20 never resolves them, while Node 22+ runs get them exactly as before.Root cause: cwd/
require.cache-based resolution has no valid anchor for an optional peer dependency of an ESM-loaded module when the app'snode_modulesis not underprocess.cwd().🤖 Generated with Claude Code