Skip to content

Conversation

@JPeer264
Copy link
Member

No description provided.

github-actions bot and others added 12 commits January 12, 2026 13:09
[Gitflow] Merge master into develop
The function became bloated and unreadable. This PR just splits the
function and refactors parts into utils.

Closes #18778 (added automatically)
(closes #18449)
(closes
[JS-1281](https://linear.app/getsentry/issue/JS-1281/appending-hostname-to-fetch-error-messages-breaks-is-network-error-and))

## Problem

As of now, the user has no chance to disallow the manipulation of fetch
errors, as we overwrite the error. This can cause problems as seen in
#18449.

## Solution

This adds a new option for the SDK (please be very critical about that
new option here, since `fetch` has no integration this has to be added
as a `init` option). `always` is the default and acts the same as it is
now, so it is acting as feature:

```ts
enhanceFetchErrorMessages: 'always' | 'report-only' | false`
```

To give the user full control of how the errors are done there are 3
settings:


| | always | report-only | false |
| ------------------------------------------ | ------- | ----------- | -
| manipulate the error message directly | ✅ | ❌ | ❌
| send only the changed message to Sentry | ✅ | ✅ | ❌


## Special attention to reviewers

When having `report-only` the generated logs locally differ from the
ones in Sentry. I am not quite sure if that would cause any problems.
This is the only question which I don't have the answer to yet

## Alternative

In case the size increase is too much, we can also have a boolean that
disables that (which is on by default)

---------

Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
… servers-side middlewares (#18680)

This PR adds a middleware wrapper to the `tanstackstart` SDK that allows
users to add tracing to their application
[middleware](https://tanstack.com/start/latest/docs/framework/react/guide/middleware).
Eventually we will want to patch this automatically, but that is a bit
tricky since it requires build-time magic. This API provides a manual
alternative for now and can later still act as a fallback for cases
where auto-instrumentation doesn't work.

**How it works**
The wrapper patches the middleware `options.server` function that gets
executed whenever a middleware is run. Each middleware invocation
creates a span with:
  - op: middleware.tanstackstart
  - origin: manual.middleware.tanstackstart
- name: The instrumentation automatically assigns the middleware name
based on the variable name assigned to the middleware.

At first I had the issue that if multiple middlewares were used they
would be nested (i.e. first middleware is parent of second etc.). This
is because the middlewares call `next()` to move down the middleware
chain, so trivially starting a span for the middleware execution would
actually create a span that would last for the current middleware and
any middlewares that come after in the middleware chain. I fixed that by
also proxying `next()`, where I end the middleware span and then also
reattach the middleware spans to the parent request span instead of the
previous middleware span.

**Usage**

```
import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';

  const [wrappedAuth, wrappedLogging] = wrapMiddlewaresWithSentry({
    authMiddleware,
    loggingMiddleware,
  });
```

**Tests**

Added E2E tests for:
- if multiple middlewares are executed we get spans for both and they
are sibling spans (i.e. children of the same parent)
- global request middleware
- global function middleware
- request middleware
- middleware that throws an exception
- middleware that does not call `next()`

Closes #18666
…meOptions (#18734)

closes #18437
closes
[JS-1272](https://linear.app/getsentry/issue/JS-1272/extend-bunoptions-with-nodeoptions)

This adds a new type `ServerRuntimeOptions` inside `@sentry/core`, a
type which can be used for all SDKs without OpenTelemetry suppport. In
case OpenTelemetry support is needed `OpenTelemetryServerRuntimeOptions`
are exported from `@sentry/node-core`, which extends
`ServerRuntimeOptions` with the options which are needed to support
OTel.

For now we don't have a nice testing strategy for Bun yet, and I didn't
want to copy paste all Node integration/e2e tests just for this, I'm
still up for suggestions.
…ons (#18800)

I was playing around with #15466 and saw that the span names for the
Prisma integration are different than the ones with actual OTel support,
such as `@sentry/node`.

Cloudflare (no `prisma:client:` prefix):

<img width="200" height="978" alt="Screenshot 2026-01-13 at 15 48 41"
src="https://github.com/user-attachments/assets/6b70a719-3c62-4799-af9c-cc15fe5aef8e"
/>

Express / Node (prefix is there):

<img width="200" height="917" alt="Screenshot 2026-01-13 at 17 18 05"
src="https://github.com/user-attachments/assets/e4677cff-b3d9-4695-871a-e64ad05b4810"
/>

Within the `@prisma/instrumentation`, which is used for our integration,
the name [is added
properly](https://github.com/prisma/prisma/blob/d4ec055ee9e13e62351bf72643fc978b3d315ae3/packages/instrumentation/src/ActiveTracingHelper.ts#L83),
but the `options` are not updated on purpose, as the source of truth is
the `name` itself - OTel also uses the name directly:
https://github.com/open-telemetry/opentelemetry-js/blob/87a0b455e5f7f36d9b05b41b6bf11d114dcc854c/packages/opentelemetry-sdk-trace-base/src/Tracer.ts#L149

There is no further explanation in #16714 why [the `name` came before
the spreading
`options`](https://github.com/getsentry/sentry-javascript/pull/16714/files#diff-595e62985088cbceb347c68deb88b69569b35edee895929d72a7f690ac13ecf7R59).

--- 

With this PR the Prisma integration does work correctly:

<img width="200" height="843" alt="Screenshot 2026-01-13 at 17 23 06"
src="https://github.com/user-attachments/assets/39fa89a3-9b31-4640-ac0c-a517d6457b62"
/>

--- 

Since the same code was copied over to Deno, I also fixed it there.
The `remix-hydrogen` E2E test started failing, pinning for now.


Closes #18814 (added automatically)
…ap` (#18809)

A customer experienced the following issue on iOS Safari 18.6.2:
`TypeError: WeakMap keys must be objects or non-registered symbols`.

The culprit is probably in web vitals `initUnique` function (which is
vendored in).

This fix adds a try/catch to handle edge cases where invalid keys are
passed to WeakMap, returning a new instance without caching when
validation fails.



Closes #18810 (added automatically)

Co-authored-by: Nicolas Hrubec <nico.hrubec@sentry.io>
[Sentry changed IPs](https://status.sentry.io/incidents/qmh29yyv8bbv)
and this caused problems with client report sending.

The current problem is that client report sending is stuck in a loop if
the client report itself cannot be sent:
`Event fails → Client Report #1 fails → Client Report #2 fails → Client
Report #3 fails → ∞`

With this fix, failed client reports are not sent anymore to prevent
this infinite feedback loop.

The offline transport already drops client reports when they cannot be
sent:

https://github.com/getsentry/sentry-javascript/blob/1b41126666e27a311884cf6f7c1ef915f95477de/packages/core/src/transports/offline.ts#L83-L86


I tested this locally by adding an entry to `/etc/hosts`: `0.0.0.0
o1.ingest.sentry.io` (the example in the issue below)

Closes #18802
closes #18782
ref #16314


Note that metrics were bundled into the base config and will be moved
into this bundle starting with v11 (ref
#18583)
…m client bundle (#18798)

Added a new `routeManifestInjection` configuration option that allows
users to exclude specific routes from the route manifest injected into
the client bundle. This addresses concerns about sensitive or unreleased
route patterns being exposed in the client-side code.

This also deprecated `disableManifestInjection` option since it would be
possible to have conflicting options present which wouldn't be a great
DX.

Users can disable it entirely by passing `false`, otherwise they can use
an object with an `exclude` property. The property can be an array of
string/regex values, or a predicate function.

The value typings prevent disabling the manifest and excluding it at the
same time, also deprecation annotations and build-time warnings should
point users towards the new option.

```ts
// Disable route manifest injection entirely
withSentryConfig(nextConfig, {
  routeManifestInjection: false
})

// Exclude specific routes
withSentryConfig(nextConfig, {
  routeManifestInjection: {
    exclude: [
      '/admin',           // Exact match
      /^\/internal\//,    // Regex: routes starting with /internal/
      /\/secret-/,        // Regex: routes containing /secret-
    ]
  }
})

// Exclude using a function
withSentryConfig(nextConfig, {
  routeManifestInjection: {
    exclude: (route) => route.includes('hidden')
  }
})
```

closes #18713
Comment on lines +70 to +79
data: {
function: generationFunctionIdentifier,
},
);
},
);
});
});
},
});
}
},
() => {
waitUntil(flushSafelyWithTimeout());
},
Copy link

Choose a reason for hiding this comment

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

Bug: The isolationScope.setTransactionName() call is incorrectly placed within an error handler, so transaction names are not set for successful generation function executions.
Severity: HIGH

Suggested Fix

Move the isolationScope.setTransactionName(transactionName) call to before the handleCallbackErrors function is invoked. This will ensure the transaction name is set on the scope for both successful and failed executions, consistent with other wrapper functions.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts#L70-L79

Potential issue: In `wrapGenerationFunctionWithSentry`, the call to
`isolationScope.setTransactionName()` is located inside the `onError` callback of
`handleCallbackErrors`. This means the transaction name will only be set when the
wrapped generation function (e.g., `generateMetadata`) throws an error. For all
successful executions, the transaction name will be missing in Sentry. This is a
functional regression that hinders observability by making it difficult to identify and
group transactions for successfully executed generation functions.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +49 to +52
isolationScope.setTransactionName(`${componentType}.${generationFunctionIdentifier} (${componentRoute})`);

const activeSpan = getActiveSpan();
if (activeSpan) {
const rootSpan = getRootSpan(activeSpan);
const sentryTrace = headersDict?.['sentry-trace'];
if (sentryTrace) {
rootSpan.setAttribute(TRANSACTION_ATTR_SENTRY_TRACE_BACKFILL, sentryTrace);
if (span) {
if (isNotFoundNavigationError(error)) {
Copy link

Choose a reason for hiding this comment

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

Bug: The transaction name is only set on failed executions of generation functions, as setTransactionName is incorrectly placed inside the onError callback.
Severity: HIGH

Suggested Fix

Move the isolationScope.setTransactionName(...) call to occur before the handleCallbackErrors function is invoked. This will ensure the transaction name is set for both successful and failed executions, restoring the behavior of the previous implementation.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts#L49-L52

Potential issue: The transaction name for generation functions like `generateMetadata`
is now set exclusively within the `onError` callback of `handleCallbackErrors`. The
`onError` callback is only executed when an error is thrown. As a result, for any
successful execution of these generation functions, the transaction name is never set.
This leads to a loss of observability in Sentry, as successful operations will not be
correctly named, making them difficult to trace and monitor. Only failed executions will
have their transaction names properly recorded.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.11 kB added added
@sentry/browser - with treeshaking flags 23.61 kB added added
@sentry/browser (incl. Tracing) 41.86 kB added added
@sentry/browser (incl. Tracing, Profiling) 46.45 kB added added
@sentry/browser (incl. Tracing, Replay) 80.46 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.15 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 85.17 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 97.36 kB added added
@sentry/browser (incl. Feedback) 41.83 kB added added
@sentry/browser (incl. sendFeedback) 29.79 kB added added
@sentry/browser (incl. FeedbackAsync) 34.79 kB added added
@sentry/browser (incl. Metrics) 26.21 kB added added
@sentry/browser (incl. Logs) 26.37 kB added added
@sentry/browser (incl. Metrics & Logs) 27.02 kB added added
@sentry/react 26.84 kB added added
@sentry/react (incl. Tracing) 44.08 kB added added
@sentry/vue 29.56 kB added added
@sentry/vue (incl. Tracing) 43.67 kB added added
@sentry/svelte 25.12 kB added added
CDN Bundle 27.61 kB added added
CDN Bundle (incl. Tracing) 42.59 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 43.5 kB added added
CDN Bundle (incl. Tracing, Replay) 79.29 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 84.71 kB added added
CDN Bundle - uncompressed 80.89 kB added added
CDN Bundle (incl. Tracing) - uncompressed 126.3 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 129.32 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 242.84 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 255.63 kB added added
@sentry/nextjs (client) 46.43 kB added added
@sentry/sveltekit (client) 42.24 kB added added
@sentry/node-core 51.91 kB added added
@sentry/node 162.15 kB added added
@sentry/node - without tracing 93.33 kB added added
@sentry/aws-serverless 108.83 kB added added

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,912 - - added
GET With Sentry 1,717 19% - added
GET With Sentry (error only) 6,059 68% - added
POST Baseline 1,193 - - added
POST With Sentry 586 49% - added
POST With Sentry (error only) 1,066 89% - added
MYSQL Baseline 3,262 - - added
MYSQL With Sentry 471 14% - added
MYSQL With Sentry (error only) 2,637 81% - added

CHANGELOG.md Outdated

- **feat(nextjs): Add routeManifestInjection option to exclude routes from client bundle ([#18798](https://github.com/getsentry/sentry-javascript/pull/18798))**

A new `routeManifestInjection` option allows you to exclude specific routes from being injected into the client bundle, helping reduce bundle size for applications with many routes.
Copy link
Member

Choose a reason for hiding this comment

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

This is not a feature for reducing bundle size, but for excluding sensitive routes in the client bundle

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch, I remove that second part of the sentence

@JPeer264 JPeer264 force-pushed the prepare-release/10.34.0 branch from e85cc63 to f9e4fc1 Compare January 14, 2026 15:25
@JPeer264 JPeer264 requested a review from chargome January 14, 2026 16:03
@JPeer264 JPeer264 merged commit 22f80b8 into master Jan 14, 2026
206 checks passed
@JPeer264 JPeer264 deleted the prepare-release/10.34.0 branch January 14, 2026 16:08
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.

6 participants