Skip to content

fix(node): Distinguish isolated transform failures from bundling in the runtime warning - #24242

Open
mydea wants to merge 3 commits into
developfrom
fn/improve-orchestrion-transform-warning
Open

fix(node): Distinguish isolated transform failures from bundling in the runtime warning#24242
mydea wants to merge 3 commits into
developfrom
fn/improve-orchestrion-transform-warning

Conversation

@mydea

@mydea mydea commented Sep 9, 2026

Copy link
Copy Markdown
Member

The runtime loader emitted the always-on [Sentry] @sentry/server-runtime-injection was bundled ... loads uninstrumented warning for any TypeError thrown while transforming a module. That equated "a transform threw a TypeError" with "the transformer was stripped by a bundler", so an unrelated per-module failure was reported as a bundling problem — pointing users at externalizing the package, which can itself break other setups.

This makes the warning honest and self-diagnosing:

  • Include the underlying error in the message, so the reader can see the actual cause instead of a hardcoded diagnosis they can't verify (debug: true still logs the full error/stack).
  • Only claim "bundled" for the transform pipeline itself going missingparse/generate is not a function, the fingerprint of a bundler tree-shaking the vendored meriyah/astring parser, which fails every module the same way — guarded by nothing having been instrumented yet (a transformer that already instrumented something is provably not stripped). Any other transform TypeError (e.g. transform is not a function) now gets a scoped Could not instrument <module> (...) message that points at reporting it, not changing the build.

Root cause of the misclassification: the callback branched on error instanceof TypeError alone. The systemic (stripped-transformer) case has a distinct signature (parse/generate is not a function), so classifying on that — with the success marker as a secondary guard — separates it from isolated per-module failures with a reasonable success rate.

A message-based heuristic is the pragmatic fix here; a follow-up upstream change to the transformer (nodejs/orchestrion-js) to throw typed/coded errors would let this classification be exact rather than string-matched.

Related to #24240, which removes the specific registration-only cause that surfaced this; this hardens the warning for any remaining/future cause.

🤖 Generated with Claude Code

@mydea
mydea requested review from isaacs and timfish September 9, 2026 11:53
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.81 kB - -
@sentry/browser - with treeshaking flags 27.12 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.01 kB - -
@sentry/browser (incl. Tracing) 49.22 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 49.22 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.15 kB - -
@sentry/browser (incl. Tracing, Replay) 88.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.94 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.44 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.38 kB - -
@sentry/browser (incl. Feedback) 46.3 kB - -
@sentry/browser (incl. sendFeedback) 33.87 kB - -
@sentry/browser (incl. FeedbackAsync) 38.99 kB - -
@sentry/browser (incl. Metrics) 29.84 kB - -
@sentry/browser (incl. Logs) 30.1 kB - -
@sentry/browser (incl. Metrics & Logs) 30.78 kB - -
@sentry/react 30.57 kB - -
@sentry/react (incl. Tracing) 51.57 kB - -
@sentry/vue 36.07 kB - -
@sentry/vue (incl. Tracing) 51.49 kB - -
@sentry/svelte 28.85 kB - -
CDN Bundle 30.56 kB - -
CDN Bundle (incl. Tracing) 49.76 kB - -
CDN Bundle (incl. Logs, Metrics) 32.83 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.7 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.48 kB - -
CDN Bundle (incl. Tracing, Replay) 87.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 93.21 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.22 kB - -
CDN Bundle - uncompressed 90.47 kB - -
CDN Bundle (incl. Tracing) - uncompressed 148.17 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.04 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 154.13 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.3 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.76 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 287.4 kB - -
@sentry/nextjs (client) 54.03 kB - -
@sentry/sveltekit (client) 49.68 kB - -
@sentry/core/server 36.99 kB - -
@sentry/core/browser 13.55 kB - -
@sentry/node 128.06 kB +0.15% +185 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.82 kB +0.26% +205 B 🔺
@sentry/node - without tracing 88.92 kB +0.24% +205 B 🔺
@sentry/node - without channel injection 107.15 kB +0.03% +22 B 🔺
@sentry/aws-serverless 97.31 kB +0.22% +210 B 🔺
@sentry/cloudflare (withSentry) - minified 202.05 kB - -
@sentry/cloudflare (withSentry) 502.91 kB - -

View base workflow run

mydea and others added 2 commits September 9, 2026 14:14
…he runtime warning

The runtime loader emitted the always-on "`@sentry/server-runtime-injection` was
bundled ... loads uninstrumented" warning for ANY `TypeError` thrown while
transforming a module, misattributing unrelated failures to bundling and
pointing users at externalizing the package (which can break other setups).

- Include the underlying error in the warning, so it is self-diagnosing rather
  than asserting a cause the reader cannot verify.
- Only claim "bundled" for the transform pipeline itself going missing
  (`parse`/`generate is not a function` — the fingerprint of a bundler
  tree-shaking the vendored parser, which fails every module the same way),
  guarded by nothing having been instrumented yet. Any other transform
  `TypeError` (e.g. `transform is not a function`) gets a scoped "Could not
  instrument <module>" message that points at reporting it, not changing the build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea
mydea force-pushed the fn/improve-orchestrion-transform-warning branch from a6b76a9 to 64ba1e8 Compare September 9, 2026 12:14

// Only the parser/generator primitives going missing means the transformer was stripped; a
// non-empty `runtime` list (something was already instrumented) proves it was not.
const pipelineStripped = /\b(?:parse|generate)\d* is not a function\b/.test(reason);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

note that this is def. not perfect, and if this is minified/renamed to something else, this will not trigger. in that case it falls back to the generic handling, which is OK I'd say.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 64ba1e8. Configure here.

Comment thread packages/server-runtime-injection/src/register.ts
…r renaming

The stripped-transformer fingerprint matched `parse`/`generate` with an optional
digit suffix, which only covers esbuild's numeric deconfliction (`parse2`).
Rollup/Vite deconflict with a `$N` suffix (`parse$1`) and production minifiers
rename to short opaque names (`e`), so a genuinely bundled pipeline fell through
to the isolated branch and told users "this is not a bundling problem".

Match the shape of the error (a bare `<ident> is not a function`) plus the fact
that nothing was ever instrumented, rather than the primitive name. Keep
`transform is not a function` as the explicit isolated carve-out (a local
dispatch read under its real name from an unbundled install) and anchor the
regex so member-expression failures (`x.y is not a function`) stay isolated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea
mydea marked this pull request as ready for review September 9, 2026 14:14
@mydea
mydea requested a review from a team as a code owner September 9, 2026 14:14
@mydea
mydea requested review from stephanie-anderson and removed request for a team September 9, 2026 14:14
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.

2 participants