Skip to content

@sentry/react 11.10.0 to 11.12.0: BrowserOptions is no longer assignable to BrowserClient constructor options (TS2345 on tunnel) #26306

Closed

Description

@JoelA510

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

11.12.0

Framework Version

React 19, TypeScript 6.0.3

Link to Sentry event

No response

Reproduction Example/SDK Setup

repro.ts:

import {
  BrowserClient,
  defaultStackParser,
  makeFetchTransport,
  type BrowserOptions,
} from '@sentry/react';

const options: BrowserOptions = {
  dsn: 'https://00000000000000000000000000000000@example.invalid/0',
  tunnel: '/tunnel',
};

export const client = new BrowserClient({
  ...options,
  integrations: [],
  stackParser: defaultStackParser,
  transport: makeFetchTransport,
});

tsconfig.json:

{
  "compilerOptions": {
    "noEmit": true,
    "target": "ESNext",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": false,
    "lib": ["dom", "esnext"],
    "skipLibCheck": true
  },
  "include": ["repro.ts"]
}

package.json:

{ "name": "repro", "private": true, "type": "module" }

Steps to Reproduce

npm install typescript@6.0.3 react@19 @sentry/react@11.9.0
npx tsc -p .          # exit 0
npm install @sentry/react@11.10.0
npx tsc -p .          # TS2345
npm install @sentry/react@11.11.0
npx tsc -p .          # TS2345
npm install @sentry/react@11.12.0
npx tsc -p .          # TS2345

It fails with strict off and with --strict (only the printed type of integrations differs, undefined[] against never[]). skipLibCheck does not hide it, because the error is in user code.

Expected Result

It compiles, as on 11.9.0. Any one of these would do:

  • BrowserClientOptions.tunnel accepts what BrowserOptions.tunnel accepts, or
  • the SDK exports the function that resolves a TunnelInit to the URL string, so a caller constructing a BrowserClient can resolve it first, or
  • the change is documented as breaking for callers who build a client from BrowserOptions.

Actual Result

On 11.10.0, 11.11.0 and 11.12.0 (strict: false):

repro.ts(13,41): error TS2345: Argument of type '{ integrations: undefined[]; stackParser: StackParser; transport: (options: BrowserTransportOptions, nativeFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) => Transport; ... 49 more ...; routeProvider?: RouteProvider; }' is not assignable to parameter of type 'BrowserClientOptions'.
  Type '{ integrations: undefined[]; stackParser: StackParser; transport: (options: BrowserTransportOptions, nativeFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) => Transport; ... 49 more ...; routeProvider?: RouteProvider; }' is not assignable to type 'ClientOptions<BrowserTransportOptions>'.
    Types of property 'tunnel' are incompatible.
      Type 'TunnelInit<TunnelOptions> & TunnelInit<BrowserTunnelOptions>' is not assignable to type 'string'.
        Type 'boolean' is not assignable to type 'string'.

Additional Context

Description

Since 11.10.0, BrowserOptions.tunnel is typed TunnelInit<BrowserTunnelOptions> (string | true | BrowserTunnelOptions), while the options that new BrowserClient(...) takes (BrowserClientOptions = ClientOptions<BrowserTransportOptions> & BrowserSpecificOptions) still type tunnel as string.

An object typed as BrowserOptions can therefore no longer be spread into the BrowserClient constructor. This compiled through 11.9.0. It is a type-level regression in a minor release: code that builds a client by hand from BrowserOptions (for example to create a second, isolated client, or to test resolved options) stops compiling.

@sentry/react npx tsc -p .
11.9.0 exit 0
11.10.0 TS2345
11.11.0 TS2345
11.12.0 (latest) TS2345

Environment: TypeScript 6.0.3, Node 24.22.2, react 19.

Where the two types diverge (11.11.0)

  • @sentry/core/build/types/types/options.d.ts: ClientOptions.tunnel?: string; and export type TunnelInit<T extends TunnelOptions = TunnelOptions> = string | true | T;, with CoreOptions now omitting 'tunnel' from Partial<ClientOptions<TO>> and redeclaring it as tunnel?: TunnelInit;
  • @sentry/browser/build/npm/types/client.d.ts: tunnel?: TunnelInit<BrowserTunnelOptions>; on the browser options, and export type BrowserClientOptions = ClientOptions<BrowserTransportOptions> & BrowserSpecificOptions;

Possibly related to the tunnel rework tracked in #25466 and #26193.

Priority

No response

Activity

  1. linear-code commented on Nov 11, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 11, 2026
  3. bunnysayzz commented on Nov 11, 2026

    @bunnysayzz

    Traced this to packages/browser/src/client.ts. BrowserOptions overrides tunnel to TunnelInit (line 99), but BrowserClientOptions (line 113) does not, so it inherits core tunnel?: string and the spread fails type-checking. The 11.10.0 managed tunnel feature widened only one side. There is a runtime gap too: init() resolves the tunnel via resolveBrowserTunnelOption, but new BrowserClient(options) never does, so true or an object would flow through unresolved. Fix would be widening the type on BrowserClientOptions and resolving it in the constructor. Happy to open a PR against develop if you give the go-ahead.

  4. assigned and unassigned on Nov 12, 2026
  5. logaretm commented on Nov 12, 2026

    @logaretm
    Member

    Hey folks, thanks for taking interest in this issue. The Tunnel improvements is an ongoing project and we would prefer to own the related work to it ourselves in the meanwhile.

    We appreciate your eagerness to take this on, but we will handle this one for now and get a fix out within the day.

  6. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 12, 2026
  7. added a commit that references this issue on Nov 16, 2026
    5e291ea
  8. github-actions commented on Nov 16, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #26313, which was included in the 11.13.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions