diff --git a/.agents/skills/bump-conventions/SKILL.md b/.agents/skills/bump-conventions/SKILL.md
index 02a2f8dbe1d6..181859b2ee0a 100644
--- a/.agents/skills/bump-conventions/SKILL.md
+++ b/.agents/skills/bump-conventions/SKILL.md
@@ -50,7 +50,6 @@ After fixing, re-run `pnpm run build:dev` and confirm it passes before verifying
## 5. Final verification
```bash
-pnpm run circularDepCheck
pnpm run fix
pnpm run test
```
diff --git a/.agents/skills/upgrade-dep/SKILL.md b/.agents/skills/upgrade-dep/SKILL.md
index e8c88d65ab86..883ff7d743a7 100644
--- a/.agents/skills/upgrade-dep/SKILL.md
+++ b/.agents/skills/upgrade-dep/SKILL.md
@@ -44,7 +44,6 @@ pnpm install
pnpm run build:dev
pnpm run dedupe-deps:fix
pnpm run fix
-pnpm run circularDepCheck
```
## Useful commands
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index d12cda804156..32fab6f55b39 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,23 +1,19 @@
-**Why:**
+## What
-**How to review:**
+
-**Unsure about:**
+## Why
-Closes #
+
-
+Closes: #
diff --git a/.github/CODEOWNERS b/.github/REVIEWERS
similarity index 92%
rename from .github/CODEOWNERS
rename to .github/REVIEWERS
index 148f6bbb4695..e534da992d3d 100644
--- a/.github/CODEOWNERS
+++ b/.github/REVIEWERS
@@ -1,5 +1,7 @@
-# Catch-all rule for shared packages
-* @getsentry/team-javascript-sdks-browser @getsentry/team-javascript-sdks-server @getsentry/team-javascript-sdks-framework
+# Reviewer routing for scripts/assign-reviewers.mjs, in CODEOWNERS syntax.
+# This is deliberately not a CODEOWNERS file: GitHub requests every matching
+# code owner team as soon as a PR opens, before the workflow requests anyone,
+# so the whole team gets notified.
# Browser, replay, feedback, and related packages
/packages/browser/ @getsentry/team-javascript-sdks-browser
diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml
index 052da6857343..098f48c191a5 100644
--- a/.github/actions/install-dependencies/action.yml
+++ b/.github/actions/install-dependencies/action.yml
@@ -22,9 +22,7 @@ runs:
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
- key:
- ${{ steps.compute_lockfile_hash.outputs.hash }}${{ runner.arch != 'X64' && format('-{0}', runner.arch) || ''
- }}
+ key: ${{ steps.compute_lockfile_hash.outputs.hash }}-${{ runner.arch }}
- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
diff --git a/.github/actions/prepare-e2e-test/action.yml b/.github/actions/prepare-e2e-test/action.yml
index 417877403d90..e7576ac001fc 100644
--- a/.github/actions/prepare-e2e-test/action.yml
+++ b/.github/actions/prepare-e2e-test/action.yml
@@ -9,6 +9,9 @@ inputs:
runtime:
description: 'The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md.'
default: ''
+ bun-version:
+ description: 'The Bun version to install, if the application needs Bun.'
+ default: '1.3.14'
deno-version:
description: 'The Deno version to install, if the application needs Deno.'
default: 'v2.8.3'
@@ -25,16 +28,14 @@ runs:
# Uses the repo's root node pin for the steps before the app is copied (installing pnpm, `test:prepare`,
# `test:validate`, `ci:copy-to-temp`). The app's own node version is set up after the copy below.
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Set up Bun
if:
inputs.test-application == 'node-exports-test-app' || contains(inputs.test-application, 'bun') || inputs.runtime
== 'bun'
uses: oven-sh/setup-bun@v2
with:
- bun-version: '1.3.14'
+ bun-version: ${{ inputs.bun-version || '1.4.2' }}
- name: Set up AWS SAM
if: contains(inputs.test-application, 'aws-serverless')
uses: aws-actions/setup-sam@v3
diff --git a/.github/actions/restore-cache/action.yml b/.github/actions/restore-cache/action.yml
index 372def6a0a7e..4112ad39ee54 100644
--- a/.github/actions/restore-cache/action.yml
+++ b/.github/actions/restore-cache/action.yml
@@ -17,7 +17,7 @@ runs:
uses: actions/cache/restore@v6.1.0
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
- key: ${{ inputs.dependency_cache_key }}${{ runner.arch != 'X64' && format('-{0}', runner.arch) || '' }}
+ key: ${{ inputs.dependency_cache_key }}-${{ runner.arch }}
- name: Restore build artifacts
uses: actions/download-artifact@v7
diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml
new file mode 100644
index 000000000000..77a4f3eb8db3
--- /dev/null
+++ b/.github/actions/setup-node/action.yml
@@ -0,0 +1,32 @@
+name: 'Set up Node'
+description: 'Sets up the Node.js version of `devEngines.runtime` in the root package.json.'
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Resolve Node.js version
+ id: node
+ run: sh "$GITHUB_ACTION_PATH/resolve-node.sh"
+ shell: sh
+
+ # The runner images don't ship this exact version. Without the cache, `actions/setup-node` fetches its version
+ # manifest through the GitHub API in every job, which uses up the repository's `GITHUB_TOKEN` rate limit.
+ - name: Restore Node.js install
+ id: node-cache
+ uses: actions/cache/restore@v6.1.0
+ with:
+ path: ${{ steps.node.outputs.cache-path }}
+ key: ${{ steps.node.outputs.cache-key }}
+
+ - name: Set up Node
+ uses: actions/setup-node@v7
+ with:
+ node-version: ${{ steps.node.outputs.version }}
+
+ # Only `develop` saves, so PRs share one entry per architecture instead of each creating their own.
+ - name: Save Node.js install
+ if: steps.node-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/develop'
+ uses: actions/cache/save@v6.1.0
+ with:
+ path: ${{ steps.node.outputs.cache-path }}
+ key: ${{ steps.node.outputs.cache-key }}
diff --git a/.github/actions/setup-node/resolve-node.sh b/.github/actions/setup-node/resolve-node.sh
new file mode 100755
index 000000000000..a611890c4023
--- /dev/null
+++ b/.github/actions/setup-node/resolve-node.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -eu
+
+version=$(jq -e -r '.devEngines.runtime.version' package.json)
+cache_path="$RUNNER_TOOL_CACHE/node/$version"
+cache_key="node-toolcache-$RUNNER_OS-$RUNNER_ARCH-$version"
+
+printf 'version=%s\ncache-path=%s\ncache-key=%s\n' "$version" "$cache_path" "$cache_key" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/assign-junior-prs.yml b/.github/workflows/assign-junior-prs.yml
new file mode 100644
index 000000000000..0b86f0577110
--- /dev/null
+++ b/.github/workflows/assign-junior-prs.yml
@@ -0,0 +1,38 @@
+name: 'PR: Assign Junior PRs to requester'
+
+on:
+ pull_request_target:
+ types:
+ - opened
+
+permissions:
+ contents: read
+
+jobs:
+ assign-requester:
+ name: Assign requester
+ runs-on: ubuntu-24.04
+ if: github.event.pull_request.user.login == 'sentry-junior[bot]'
+ steps:
+ # Matching Slack names to GitHub users lists team members, which needs org `members: read`.
+ - name: Generate GitHub App token
+ id: app-token
+ uses: actions/create-github-app-token@v3
+ with:
+ client-id: ${{ vars.GITFLOW_APP_ID }}
+ private-key: ${{ secrets.GITFLOW_APP_PRIVATE_KEY }}
+
+ - name: Checkout base branch
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: |
+ scripts/junior-requesters.mjs
+ sparse-checkout-cone-mode: false
+
+ - name: Assign requester
+ uses: actions/github-script@v9
+ with:
+ github-token: ${{ steps.app-token.outputs.token }}
+ script: |
+ const { assignJuniorRequesters } = await import('${{ github.workspace }}/scripts/junior-requesters.mjs');
+ await assignJuniorRequesters({ github, context, core });
diff --git a/.github/workflows/assign-reviewers.yml b/.github/workflows/assign-reviewers.yml
new file mode 100644
index 000000000000..60e541dcb775
--- /dev/null
+++ b/.github/workflows/assign-reviewers.yml
@@ -0,0 +1,48 @@
+name: 'PR: Assign reviewers'
+
+on:
+ # pull_request_target so this also runs for fork PRs. It only checks out the base branch,
+ # never the PR's code.
+ pull_request_target:
+ types:
+ - opened
+ - reopened
+ - ready_for_review
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
+ cancel-in-progress: false
+
+permissions:
+ contents: read
+
+jobs:
+ assign-reviewers:
+ name: Assign reviewers
+ runs-on: ubuntu-24.04
+ if: github.event.pull_request.draft == false
+ steps:
+ # Listing team members needs org `members: read`, which GITHUB_TOKEN can't have.
+ - name: Generate GitHub App token
+ id: app-token
+ uses: actions/create-github-app-token@v3
+ with:
+ client-id: ${{ vars.GITFLOW_APP_ID }}
+ private-key: ${{ secrets.GITFLOW_APP_PRIVATE_KEY }}
+
+ - name: Checkout base branch
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: |
+ .github/REVIEWERS
+ scripts/assign-reviewers.mjs
+ scripts/junior-requesters.mjs
+ sparse-checkout-cone-mode: false
+
+ - name: Assign reviewers
+ uses: actions/github-script@v9
+ with:
+ github-token: ${{ steps.app-token.outputs.token }}
+ script: |
+ const { assignReviewers } = await import('${{ github.workspace }}/scripts/assign-reviewers.mjs');
+ await assignReviewers({ github, context, core });
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 59211cdc3d6d..53c2cf9ab6b4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,4 +1,5 @@
name: 'CI: Build & Test'
+# Full-CI baseline for the Nuxt production/development split benchmark.
on:
push:
branches:
@@ -92,9 +93,7 @@ jobs:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
@@ -155,6 +154,40 @@ jobs:
$GITHUB_OUTPUT
working-directory: dev-packages/e2e-tests
+ - name: Build tarballs and bundles
+ run: |
+ pnpm run clean:tarballs
+ pnpm exec nx run-many -t build:tarball build:bundle --parallel=4
+
+ - name: Upload tarball artifacts
+ uses: actions/upload-artifact@v7
+ with:
+ name: build-tarball-output
+ path: ${{ env.TARBALL_ARTIFACT_GLOB }}
+ if-no-files-found: error
+ retention-days: 4
+ compression-level: 6
+ overwrite: true
+
+ - name: Upload test-utils tarball artifact
+ uses: actions/upload-artifact@v7
+ with:
+ name: build-test-utils-tarball-output
+ path: dev-packages/test-utils/*.tgz
+ if-no-files-found: error
+ retention-days: 4
+ compression-level: 6
+ overwrite: true
+
+ - name: Upload bundle artifacts
+ uses: actions/upload-artifact@v7
+ with:
+ name: build-bundle-output
+ path: ${{ env.BUNDLE_ARTIFACT_GLOB }}
+ retention-days: 4
+ compression-level: 6
+ overwrite: true
+
outputs:
dependency_cache_key: ${{ steps.install_dependencies.outputs.cache_key }}
changed_node_integration:
@@ -206,9 +239,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore NX cache
uses: actions/cache/restore@v6.1.0
with:
@@ -234,45 +265,6 @@ jobs:
compression-level: 6
overwrite: true
- job_build_bundles:
- name: Build bundles
- needs: [job_get_metadata, job_build]
- timeout-minutes: 10
- runs-on: ubuntu-24.04-arm
- steps:
- - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
- uses: actions/checkout@v7
- with:
- ref: ${{ env.HEAD_COMMIT }}
- - name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
- - name: Restore NX cache
- uses: actions/cache/restore@v6.1.0
- with:
- path: |
- .nx/cache
- .nx/workspace-data
- key: ${{ env.NX_CACHE_KEY }}-${{ runner.arch }}
-
- - name: Restore caches
- uses: ./.github/actions/restore-cache
- with:
- dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
-
- - name: Build bundles
- run: pnpm run build:bundle
-
- - name: Upload build artifacts
- uses: actions/upload-artifact@v7
- with:
- name: build-bundle-output
- path: ${{ env.BUNDLE_ARTIFACT_GLOB }}
- retention-days: 4
- compression-level: 6
- overwrite: true
-
job_check_branches:
name: Check PR branches
needs: job_get_metadata
@@ -290,7 +282,7 @@ jobs:
job_size_check:
name: Size Check
- needs: [job_get_metadata, job_build, job_build_bundles]
+ needs: [job_get_metadata, job_build]
timeout-minutes: 15
runs-on: ubuntu-24.04-arm
if:
@@ -302,9 +294,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
@@ -334,9 +324,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
@@ -348,8 +336,6 @@ jobs:
run: pnpm run lint:es-compatibility
- name: Lint types
run: pnpm run lint:types
- - name: Check for circular dependencies
- run: pnpm run circularDepCheck
- name: Check for dts files that reference stuff in the temporary build folder
run: |
if grep -r --include "*.d.ts" --exclude-dir ".nx" 'import("@sentry(-internal)?/[^/]*/build' .; then
@@ -382,9 +368,7 @@ jobs:
- name: Install pnpm
uses: ./.github/actions/install-pnpm
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Check that pnpm-lock.yaml is stable
@@ -408,9 +392,7 @@ jobs:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
@@ -420,7 +402,7 @@ jobs:
job_artifacts:
name: Upload Artifacts
- needs: [job_get_metadata, job_build, job_build_layer, job_build_bundles, job_build_tarballs]
+ needs: [job_get_metadata, job_build, job_build_layer]
runs-on: ubuntu-24.04
# Build artifacts are only needed for releasing workflow.
if: needs.job_get_metadata.outputs.is_release == 'true'
@@ -430,9 +412,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
@@ -488,9 +468,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
@@ -521,9 +499,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
@@ -548,9 +524,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Set up Deno
uses: denoland/setup-deno@v2.0.5
with:
@@ -616,7 +590,7 @@ jobs:
name:
Playwright ${{ matrix.bundle }}${{ matrix.project && matrix.project != 'chromium' && format(' {0}',
matrix.project) || ''}}${{ matrix.shard && format(' ({0}/{1})', matrix.shard, matrix.shards) || ''}} Tests
- needs: [job_get_metadata, job_build, job_build_bundles]
+ needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-24.04-large-js
timeout-minutes: 25
@@ -634,8 +608,6 @@ jobs:
- bundle_tracing
- bundle_tracing_logs_metrics
- bundle_tracing_replay
- - bundle_tracing_replay_logs_metrics
- - bundle_tracing_replay_feedback
- bundle_tracing_replay_feedback_logs_metrics
- bundle_tracing_replay_feedback_logs_metrics_min
project:
@@ -654,19 +626,51 @@ jobs:
- bundle: esm
project: chromium
shard: 1
- shards: 4
+ shards: 6
- bundle: esm
project: chromium
shard: 2
- shards: 4
+ shards: 6
- bundle: esm
project: chromium
shard: 3
- shards: 4
+ shards: 6
- bundle: esm
project: chromium
shard: 4
- shards: 4
+ shards: 6
+ - bundle: esm
+ project: chromium
+ shard: 5
+ shards: 6
+ - bundle: esm
+ project: chromium
+ shard: 6
+ shards: 6
+ - bundle: bundle_tracing_replay_feedback
+ project: chromium
+ shard: 1
+ shards: 3
+ - bundle: bundle_tracing_replay_feedback
+ project: chromium
+ shard: 2
+ shards: 3
+ - bundle: bundle_tracing_replay_feedback
+ project: chromium
+ shard: 3
+ shards: 3
+ - bundle: bundle_tracing_replay_logs_metrics
+ project: chromium
+ shard: 1
+ shards: 3
+ - bundle: bundle_tracing_replay_logs_metrics
+ project: chromium
+ shard: 2
+ shards: 3
+ - bundle: bundle_tracing_replay_logs_metrics
+ project: chromium
+ shard: 3
+ shards: 3
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
@@ -674,9 +678,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
@@ -715,7 +717,7 @@ jobs:
job_browser_loader_tests:
name: PW ${{ matrix.bundle }} Tests
- needs: [job_get_metadata, job_build, job_build_bundles]
+ needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-24.04
timeout-minutes: 15
@@ -737,9 +739,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
@@ -773,6 +773,39 @@ jobs:
overwrite: true
retention-days: 7
+ # Runs the CDN bundles in the oldest Chromium we support. Chromium snapshots only exist for x64.
+ job_browser_min_version_tests:
+ name: Minimum Chromium Version Tests
+ needs: [job_get_metadata, job_build]
+ if: needs.job_build.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 5
+ steps:
+ - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
+ uses: actions/checkout@v7
+ with:
+ ref: ${{ env.HEAD_COMMIT }}
+ - name: Set up Node
+ uses: ./.github/actions/setup-node
+ - name: Restore caches
+ uses: ./.github/actions/restore-cache
+ with:
+ dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
+
+ - name: Restore build bundle artifacts
+ uses: actions/download-artifact@v8
+ with:
+ name: build-bundle-output
+ path: ${{ env.BUNDLE_ARTIFACT_DOWNLOAD_PATH }}
+
+ # Chromium itself isn't cached: `run.mjs` downloads the 127 MB zip on each run, which is about as quick as a
+ # cache restore.
+ - name: Install Chromium dependencies
+ run: dev-packages/browser-min-version-tests/install-deps.sh
+
+ - name: Run tests
+ run: node dev-packages/browser-min-version-tests/run.mjs
+
job_node_integration_tests:
name: Node (${{ matrix.node }}) Integration Tests (${{ matrix.shard }}/${{ matrix.shards }})
needs: [job_get_metadata, job_build]
@@ -784,19 +817,9 @@ jobs:
strategy:
fail-fast: false
matrix:
- node: [20.19, 22, 24, 26]
- shard: [1, 2, 3, 4]
- shards: [4]
- include:
- - node: '^27.0.0-0'
- shard: 1
- shards: 3
- - node: '^27.0.0-0'
- shard: 2
- shards: 3
- - node: '^27.0.0-0'
- shard: 3
- shards: 3
+ node: [20.19, 22, 24, 26, '^27.0.0-0']
+ shard: [1, 2, 3, 4, 5, 6]
+ shards: [6]
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v7
@@ -877,9 +900,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
@@ -948,7 +969,7 @@ jobs:
run: pnpm run test
job_bun_integration_tests:
- name: Bun (${{ matrix.bun }}) Integration Tests (${{ matrix.shard }}/2)
+ name: Bun (${{ matrix.bun }}) Integration Tests (${{ matrix.shard }}/4)
needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_bun_integration == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-24.04-arm
@@ -958,16 +979,14 @@ jobs:
matrix:
# 1.3.14 is the oldest supported Bun version
bun: ['1.3.14', '1.4']
- shard: [1, 2]
+ shard: [1, 2, 3, 4]
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v7
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
@@ -979,10 +998,10 @@ jobs:
- name: Run integration tests
working-directory: dev-packages/bun-integration-tests
- run: pnpm run test --shard=${{ matrix.shard }}/2
+ run: pnpm run test --shard=${{ matrix.shard }}/4
job_deno_integration_tests:
- name: Deno Integration Tests (${{ matrix.shard }}/2)
+ name: Deno Integration Tests (${{ matrix.shard }}/4)
needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_deno_integration == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-24.04-arm
@@ -990,16 +1009,14 @@ jobs:
strategy:
fail-fast: false
matrix:
- shard: [1, 2]
+ shard: [1, 2, 3, 4]
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v7
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Set up Deno
uses: denoland/setup-deno@v2.0.5
with:
@@ -1021,75 +1038,14 @@ jobs:
- name: Run shared Node integration tests
working-directory: dev-packages/deno-integration-tests
# Tedious runs in the dedicated SQL Server job because its database container requires x86.
- run: pnpm run test:node-suites --shard=${{ matrix.shard }}/2 --exclude '**/tracing/tedious/**'
-
- job_build_tarballs:
- name: Build tarballs
- # We want to run this if:
- # - The build job was successful, not skipped
- if: |
- always() &&
- needs.job_build.result == 'success'
- needs: [job_get_metadata, job_build]
- runs-on: ubuntu-24.04-arm
- timeout-minutes: 15
- steps:
- - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
- uses: actions/checkout@v7
- with:
- ref: ${{ env.HEAD_COMMIT }}
- - name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
- - name: Restore NX cache
- uses: actions/cache/restore@v6.1.0
- with:
- path: |
- .nx/cache
- .nx/workspace-data
- key: ${{ env.NX_CACHE_KEY }}-${{ runner.arch }}
-
- - name: Restore caches
- uses: ./.github/actions/restore-cache
- with:
- dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
-
- - name: Build tarballs
- run: |
- pnpm run clean:tarballs
- pnpm run build:tarballs --parallel=4
-
- - name: Upload tarball artifacts
- uses: actions/upload-artifact@v7
- with:
- name: build-tarball-output
- path: ${{ env.TARBALL_ARTIFACT_GLOB }}
- if-no-files-found: error
- retention-days: 4
- compression-level: 6
- overwrite: true
-
- - name: Upload test-utils tarball artifact
- uses: actions/upload-artifact@v7
- with:
- name: build-test-utils-tarball-output
- path: dev-packages/test-utils/*.tgz
- if-no-files-found: error
- retention-days: 4
- compression-level: 6
- overwrite: true
+ run: pnpm run test:node-suites --shard=${{ matrix.shard }}/4 --exclude '**/tracing/tedious/**'
# GitHub Actions allows at most 256 jobs in one matrix, so the E2E tests are split into two jobs that share `env`
# and `steps`.
job_e2e_tests_1:
name: E2E ${{ matrix.label || matrix.test-application }} Test
- # We need to add the `always()` check here because the previous step has this as well :(
- # See: https://github.com/actions/runner/issues/2205
- if:
- always() && needs.job_build_tarballs.result == 'success' && needs.job_build.outputs.e2e-matrix-1 !=
- '{"include":[]}'
- needs: [job_get_metadata, job_build, job_build_tarballs]
+ if: always() && needs.job_build.result == 'success' && needs.job_build.outputs.e2e-matrix-1 != '{"include":[]}'
+ needs: [job_get_metadata, job_build]
runs-on: ubuntu-24.04
timeout-minutes: 15
# We just use a dummy DSN here, only send to the tunnel anyhow
@@ -1103,6 +1059,7 @@ jobs:
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
# The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md
RUNTIME: ${{ matrix.runtime }}
+ SENTRY_E2E_TEST_SHARD: ${{ matrix.test-shard }}
# Without the root node_modules, `pnpm run` would first install the whole workspace.
pnpm_config_verify_deps_before_run: 'false'
strategy:
@@ -1118,6 +1075,7 @@ jobs:
with:
test-application: ${{ matrix.test-application }}
runtime: ${{ matrix.runtime }}
+ bun-version: ${{ matrix.bun-version }}
deno-version: ${{ matrix.deno-version }}
# Installs Playwright while the app builds. Keep it right before the build: the runner sets up a background
@@ -1158,10 +1116,8 @@ jobs:
job_e2e_tests_2:
name: E2E ${{ matrix.label || matrix.test-application }} Test
- if:
- always() && needs.job_build_tarballs.result == 'success' && needs.job_build.outputs.e2e-matrix-2 !=
- '{"include":[]}'
- needs: [job_get_metadata, job_build, job_build_tarballs]
+ if: always() && needs.job_build.result == 'success' && needs.job_build.outputs.e2e-matrix-2 != '{"include":[]}'
+ needs: [job_get_metadata, job_build]
runs-on: ubuntu-24.04
timeout-minutes: 15
env: *e2e-env
@@ -1172,9 +1128,9 @@ jobs:
job_e2e_aws_layer_tests:
name: E2E ${{ matrix.label || matrix.test-application }} Test
- needs: [job_get_metadata, job_build, job_build_layer, job_build_tarballs]
+ needs: [job_get_metadata, job_build, job_build_layer]
if: >-
- always() && needs.job_build_tarballs.result == 'success' && needs.job_build_layer.result == 'success' &&
+ always() && needs.job_build.result == 'success' && needs.job_build_layer.result == 'success' &&
needs.job_build.outputs.e2e-matrix-aws-layer != '{"include":[]}'
runs-on: ubuntu-24.04
timeout-minutes: 15
@@ -1190,13 +1146,11 @@ jobs:
job_optional_e2e_tests:
name: E2E Tests (optional)
# We only run E2E tests for non-fork PRs because the E2E tests require secrets to work and they can't be accessed from forks
- # We need to add the `always()` check here because the previous step has this as well :(
- # See: https://github.com/actions/runner/issues/2205
if:
- always() && needs.job_get_metadata.outputs.is_release != 'true' && needs.job_build_tarballs.result == 'success' &&
+ always() && needs.job_get_metadata.outputs.is_release != 'true' && needs.job_build.result == 'success' &&
needs.job_build.outputs.e2e-matrix-optional != '{"include":[]}' && (github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
- needs: [job_get_metadata, job_build, job_build_tarballs]
+ needs: [job_get_metadata, job_build]
# This job only waits for optional-e2e.yml, which can take most of an hour.
runs-on: ubuntu-24.04
timeout-minutes: 60
@@ -1209,9 +1163,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Install pnpm
uses: ./.github/actions/install-pnpm
# Only install what the action needs
@@ -1229,9 +1181,7 @@ jobs:
needs:
[
job_build,
- job_build_bundles,
job_build_layer,
- job_build_tarballs,
job_browser_unit_tests,
job_bun_unit_tests,
job_deno_unit_tests,
@@ -1244,6 +1194,7 @@ jobs:
job_deno_integration_tests,
job_browser_playwright_tests,
job_browser_loader_tests,
+ job_browser_min_version_tests,
job_e2e_tests_1,
job_e2e_tests_2,
job_e2e_aws_layer_tests,
diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml
index 422cecffa19c..f8ef50f4da66 100644
--- a/.github/workflows/canary.yml
+++ b/.github/workflows/canary.yml
@@ -85,6 +85,7 @@ jobs:
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
# The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md
RUNTIME: ${{ matrix.runtime }}
+ SENTRY_E2E_TEST_SHARD: ${{ matrix.test-shard }}
# Without the root node_modules, `pnpm run` would first install the whole workspace.
pnpm_config_verify_deps_before_run: 'false'
strategy:
@@ -101,6 +102,7 @@ jobs:
with:
test-application: ${{ matrix.test-application }}
runtime: ${{ matrix.runtime }}
+ bun-version: ${{ matrix.bun-version }}
deno-version: ${{ matrix.deno-version }}
- name: Build E2E app
diff --git a/.github/workflows/cleanup-e2e-workers.yml b/.github/workflows/cleanup-e2e-workers.yml
index 69aae225e408..4b986b32805e 100644
--- a/.github/workflows/cleanup-e2e-workers.yml
+++ b/.github/workflows/cleanup-e2e-workers.yml
@@ -20,6 +20,7 @@ jobs:
worker-prefix:
- e2e-send-to-sentry
- e2e-flue-send-to-sentry
+ - e2e-without-tracing-send-to-sentry
steps:
- name: Set up Node
uses: actions/setup-node@v7
diff --git a/.github/workflows/optional-e2e.yml b/.github/workflows/optional-e2e.yml
index 0fc020c9b327..48c469acacb1 100644
--- a/.github/workflows/optional-e2e.yml
+++ b/.github/workflows/optional-e2e.yml
@@ -63,6 +63,7 @@ jobs:
E2E_PR_NUMBER: ${{ inputs.pr_number }}
# The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md
RUNTIME: ${{ matrix.runtime }}
+ SENTRY_E2E_TEST_SHARD: ${{ matrix.test-shard }}
# Without the root node_modules, `pnpm run` would first install the whole workspace.
pnpm_config_verify_deps_before_run: 'false'
strategy:
@@ -79,6 +80,7 @@ jobs:
with:
test-application: ${{ matrix.test-application }}
runtime: ${{ matrix.runtime }}
+ bun-version: ${{ matrix.bun-version }}
deno-version: ${{ matrix.deno-version }}
artifacts-run-id: ${{ inputs.build_run_id }}
github-token: ${{ github.token }}
@@ -125,9 +127,7 @@ jobs:
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
- uses: actions/setup-node@v7
- with:
- node-version-file: 'package.json'
+ uses: ./.github/actions/setup-node
- name: Install pnpm
uses: ./.github/actions/install-pnpm
- name: Install action dependencies
diff --git a/.madgerc b/.madgerc
deleted file mode 100644
index b407c6b4b14f..000000000000
--- a/.madgerc
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "detectiveOptions": {
- "ts": {
- "skipTypeImports": true
- }
- }
-}
diff --git a/.oxlintrc.base.json b/.oxlintrc.base.json
index 3c42d69b4bb4..73a31b05f3b8 100644
--- a/.oxlintrc.base.json
+++ b/.oxlintrc.base.json
@@ -79,6 +79,13 @@
"sdk/no-unfiltered-url-attributes": "error"
}
},
+ {
+ // Type-only imports are erased at build time, so they cannot cause load-order bugs.
+ "files": ["**/src/**"],
+ "rules": {
+ "import/no-cycle": ["error", { "ignoreTypes": true }]
+ }
+ },
{
// The rule itself decides which files are browser-facing (see `no-unguarded-span-apis.js`);
// oxlint resolves `files` globs relative to each package's own config, so scoping it to
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 5c59e098d55e..750acd5f866f 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -52,33 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
- // Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
- // NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
- // install the recommended extension Tasks Shell Input.
- {
- "name": "Debug playwright tests (just open file)",
- "type": "pwa-node",
- "cwd": "${workspaceFolder}/packages/${input:getPackageName}",
- "request": "launch",
- "runtimeExecutable": "pnpm",
- "runtimeArgs": [
- // `nodemon` is basically `node --watch`
- "nodemon",
- // be default it only watches JS files, so have it watch TS files instead
- "--ext",
- "ts",
- "${workspaceFolder}/node_modules/playwright/node_modules/.bin/playwright",
- "test",
- "${file}"
- ],
- "skipFiles": ["/**"],
- "outFiles": ["${workspaceFolder}/**/*.js", "!**/node_modules/**"],
- "sourceMaps": true,
- "smartStep": true,
- "internalConsoleOptions": "openOnSessionStart",
- // show stdout and stderr output in the debug console
- "outputCapture": "std"
- },
// @sentry/nextjs - Run a specific integration test file
// Must have test file in currently active tab when hitting the play button, and must already have run `pnpm install` in test app directory
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cae8ddfbdbb1..1a2040fb3be8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,170 @@
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
+## 11.13.0
+
+### Important Changes
+
+- **feat(sveltekit): Mark pageloads of prerendered and Vercel ISR pages ([#26301](https://github.com/getsentry/sentry-javascript/pull/26301), [#26307](https://github.com/getsentry/sentry-javascript/pull/26307))**
+
+ When SvelteKit serves a page that it rendered earlier, the pageload now has the `page.server_rendering.type: static` attribute. This covers pages prerendered during `vite build` and pages that Vercel caches with ISR (`config.isr`). For an ISR page, the pageload also links to the request that rendered the page, if that request was sampled.
+
+ Before, every visitor of a cached ISR page continued the trace of that one request. Now each pageload starts its own trace. Pages with `ssr = false` get no attribute, because the server rendered none of their content.
+
+- **feat(nuxt): Mark pageloads of cached pages ([#26305](https://github.com/getsentry/sentry-javascript/pull/26305))**
+
+ When Nuxt serves a cached or prerendered page, for example with a `swr` or `isr` route rule, the pageload now has the `page.server_rendering.type: static` attribute and starts its own trace. If the request that rendered the cached page was sampled, the pageload also links to it. So visitors of a cached page no longer continue the trace of the request that rendered it.
+
+- **fix(core): Set `url.scheme` without colon and `url.port` as a number ([#26284](https://github.com/getsentry/sentry-javascript/pull/26284))**
+
+ HTTP spans that the SDK builds from a `URL` now send `url.scheme` without the trailing colon (`https` instead of `https:`) and `url.port` as a number instead of a string, as the Sentry conventions define them and as Node `http.server` spans already do. This changes `http.server` spans from `@sentry/cloudflare`, `Bun.serve`, Deno and Nitro, and outgoing `node:http` client spans. Update saved queries, alerts and dashboards that filter on `url.scheme:"https:"` or on `url.port` as a string.
+
+- **feat(cloudflare): Continue the Cloudflare trace of the invocation ([#25613](https://github.com/getsentry/sentry-javascript/pull/25613))**
+
+ When tracing is not set up (no `tracesSampleRate` or `tracesSampler`), errors and logs from fetch, scheduled, queue and email handlers and from `WorkerEntrypoint` RPC methods now get the trace id that Cloudflare gives the invocation. With this trace id, you can find the Cloudflare spans and logs of an error in Workers Observability. This needs workerd 1.20261009.1 or newer and Workers Observability turned on. An incoming Sentry trace still has precedence.
+
+ The `parent_span_id` of these events is the id of a Cloudflare span. This span is in Sentry only when you export your Workers traces to Sentry.
+
+- **feat(server-utils): Record Bedrock prompts and responses ([#26249](https://github.com/getsentry/sentry-javascript/pull/26249), [#26362](https://github.com/getsentry/sentry-javascript/pull/26362), [#26414](https://github.com/getsentry/sentry-javascript/pull/26414))**
+
+ Amazon Bedrock spans from `awsIntegration` now record prompts, system instructions, tool definitions and responses by default, as the other AI integrations do. This applies to the `Converse`, `ConverseStream`, `InvokeModel` and `InvokeModelWithResponseStream` commands.
+
+ To stop recording prompts or responses for all AI integrations, set `dataCollection: { genAI: { inputs: false, outputs: false } }`. To stop it only for Bedrock, use the new `awsIntegration` options, which take precedence over `dataCollection.genAI`:
+
+ ```js
+ Sentry.init({
+ integrations: [Sentry.awsIntegration({ recordInputs: false, recordOutputs: false })],
+ });
+ ```
+
+### Other Changes
+
+- feat(aws-serverless): Add HTTP request and response attributes to function.aws spans ([#26226](https://github.com/getsentry/sentry-javascript/pull/26226))
+- feat(aws-serverless): Ignore static asset and preflight invocations by default ([#26228](https://github.com/getsentry/sentry-javascript/pull/26228))
+- feat(bundler-plugins): Delete source maps with `deleteSourcemapsAfterUpload: true` when no upload runs ([#26281](https://github.com/getsentry/sentry-javascript/pull/26281))
+- feat(bundler-plugins): Enable external source maps and delete them after upload in the esbuild plugin ([#25648](https://github.com/getsentry/sentry-javascript/pull/25648))
+- feat(cloudflare): Instrument `trace` and `tailStream` handlers ([#26250](https://github.com/getsentry/sentry-javascript/pull/26250))
+- feat(core): Add `getTraceServerTimingHeader` and `isSharedCacheable` ([#26325](https://github.com/getsentry/sentry-javascript/pull/26325))
+- feat(core): capture MCP OAuth client names per request ([#24508](https://github.com/getsentry/sentry-javascript/pull/24508))
+- feat(core): Support Zod 4 errors in zodErrorsIntegration ([#25756](https://github.com/getsentry/sentry-javascript/pull/25756))
+- feat(nextjs): Emit the tunnel route handler ([#25424](https://github.com/getsentry/sentry-javascript/pull/25424))
+- feat(nextjs): Send the render start of a cached page to the browser ([#26397](https://github.com/getsentry/sentry-javascript/pull/26397))
+- feat(nextjs): Send the trace in the `Server-Timing` header of document responses ([#26107](https://github.com/getsentry/sentry-javascript/pull/26107))
+- feat(nextjs): Use the Bun integrations when Next.js runs on Bun ([#26294](https://github.com/getsentry/sentry-javascript/pull/26294))
+- feat(nextjs): Use the Deno fetch integration when Next.js runs on Deno ([#26295](https://github.com/getsentry/sentry-javascript/pull/26295))
+- feat(node): Capture the original job error for failed BullMQ jobs ([#26352](https://github.com/getsentry/sentry-javascript/pull/26352))
+- feat(node): Instrument HTTP/2 servers that use the compat API ([#25992](https://github.com/getsentry/sentry-javascript/pull/25992))
+- feat(node): Publish flat CJS builds to cut `@sentry/node` startup time ([#25968](https://github.com/getsentry/sentry-javascript/pull/25968))
+- feat(nuxt): Instrument Nitro v3 cache storage ([#25951](https://github.com/getsentry/sentry-javascript/pull/25951))
+- feat(nuxt): Send the render start of a cached page to the browser ([#26399](https://github.com/getsentry/sentry-javascript/pull/26399))
+- feat(react-router): Export createSentryHandleError from the Cloudflare entry ([#26343](https://github.com/getsentry/sentry-javascript/pull/26343))
+- feat(server-utils): Add pi-ai integration ([#25937](https://github.com/getsentry/sentry-javascript/pull/25937))
+- feat(server-utils): Enable pi-ai by default & use it for Flue & pi-durable ([#25940](https://github.com/getsentry/sentry-javascript/pull/25940))
+- feat(sveltekit): Send the render start of a cached page to the browser ([#26398](https://github.com/getsentry/sentry-javascript/pull/26398))
+- feat(tanstackstart-react): Initialize the SDK when the Nitro server starts ([#26224](https://github.com/getsentry/sentry-javascript/pull/26224))
+- fix(anthropic): End and mark messages.stream() span as cancelled on abort ([#26236](https://github.com/getsentry/sentry-javascript/pull/26236))
+- fix(astro, cloudflare): Run the Cloudflare SDK on the server for Cloudflare Pages ([#26188](https://github.com/getsentry/sentry-javascript/pull/26188))
+- fix(browser): Accept managed tunnel options in the `BrowserClient` constructor ([#26313](https://github.com/getsentry/sentry-javascript/pull/26313))
+- fix(browser): Handle parentheses in function names in stack parsers ([#26233](https://github.com/getsentry/sentry-javascript/pull/26233))
+- fix(browser): Instrument empty-URL XHR and show the page URL in breadcrumbs ([#26201](https://github.com/getsentry/sentry-javascript/pull/26201))
+- fix(browser): Send same-origin string tunnels as `application/x-sentry-envelope` ([#26299](https://github.com/getsentry/sentry-javascript/pull/26299))
+- fix(browser): Skip CLS on browsers without Array.prototype.at ([#26347](https://github.com/getsentry/sentry-javascript/pull/26347))
+- fix(bundler-plugins): Keep uploading when a directory has no source maps ([#26092](https://github.com/getsentry/sentry-javascript/pull/26092))
+- fix(bundler-plugins): Skip default commit association on Vercel builds that --auto can't resolve ([#26320](https://github.com/getsentry/sentry-javascript/pull/26320))
+- fix(bundler-plugins): Stop defaulting `url` to sentry.io ([#26252](https://github.com/getsentry/sentry-javascript/pull/26252))
+- fix(cloudflare): Capture errors that fail a workflow run outside a step callback ([#26316](https://github.com/getsentry/sentry-javascript/pull/26316))
+- fix(cloudflare): Forward method, headers and body when a Request is passed as fetch init ([#26368](https://github.com/getsentry/sentry-javascript/pull/26368))
+- fix(cloudflare): Have `@flue/runtime` provide its own namespace ([#25935](https://github.com/getsentry/sentry-javascript/pull/25935))
+- fix(cloudflare): Skip auto-instrument warning for TanStack Start tunnel shim ([#26239](https://github.com/getsentry/sentry-javascript/pull/26239))
+- fix(core): Always return a string from `_enhanceErrorWithSentryInfo` ([#26349](https://github.com/getsentry/sentry-javascript/pull/26349))
+- fix(nextjs): Inject build values into instrumentation for an external server SDK ([#26292](https://github.com/getsentry/sentry-javascript/pull/26292))
+- fix(nextjs): Run Turbopack loaders in worker threads on Bun ([#26293](https://github.com/getsentry/sentry-javascript/pull/26293))
+- fix(opentelemetry): Keep live context link when passing a scope to withScope ([#26234](https://github.com/getsentry/sentry-javascript/pull/26234))
+- fix(replay): Minify the compression worker to ES2020 ([#26355](https://github.com/getsentry/sentry-javascript/pull/26355))
+- fix(server-runtime-injection): Register the CJS loader hook from the CJS build ([#26278](https://github.com/getsentry/sentry-javascript/pull/26278))
+- fix(server-utils): Count Google GenAI tool-use prompt tokens as input tokens ([#25834](https://github.com/getsentry/sentry-javascript/pull/25834))
+- fix(server-utils): Instrument deps excluded from the Vite dep optimizer ([#26264](https://github.com/getsentry/sentry-javascript/pull/26264))
+- fix(server-utils): Keep usage and tool errors when ai omits channel results ([#26150](https://github.com/getsentry/sentry-javascript/pull/26150))
+- fix(server-utils): Keep Workers AI streamed tool calls that have no index ([#25835](https://github.com/getsentry/sentry-javascript/pull/25835))
+- fix(server-utils): Mark AI spans as cancelled when the caller aborts ([#26297](https://github.com/getsentry/sentry-javascript/pull/26297))
+- fix(server-utils): Read GLOBAL_OBJ at call time in Nitro integration ([#26300](https://github.com/getsentry/sentry-javascript/pull/26300))
+- fix(server-utils): Record Anthropic chat spans for thread and tool-runner streams on 1.2+ ([#25931](https://github.com/getsentry/sentry-javascript/pull/25931))
+- fix(server-utils): Record output of Workers AI chat-completion responses ([#26175](https://github.com/getsentry/sentry-javascript/pull/26175))
+- fix(server-utils): Trace Vercel AI streamObject on ai v4-v6 ([#26382](https://github.com/getsentry/sentry-javascript/pull/26382))
+- fix(server-utils): Use the client's provider name for Anthropic platform clients ([#26119](https://github.com/getsentry/sentry-javascript/pull/26119))
+- fix(solidstart): Keep build-time tooling out of SolidStart 2 server bundles ([#26277](https://github.com/getsentry/sentry-javascript/pull/26277))
+- ref(server-runtime-injection): Say when hook registration fails because the deployment is missing a file ([#26272](https://github.com/getsentry/sentry-javascript/pull/26272))
+
+
+ Internal Changes
+
+- chore(build): Remove build:watch scripts ([#26350](https://github.com/getsentry/sentry-javascript/pull/26350))
+- chore(build): Replace es-check with an acorn-based script ([#26321](https://github.com/getsentry/sentry-javascript/pull/26321))
+- chore(bundler-plugins): Type-check tests via lint:types ([#26345](https://github.com/getsentry/sentry-javascript/pull/26345))
+- chore(ci): Add Warden gha-security-review and skill-scanner ([#26269](https://github.com/getsentry/sentry-javascript/pull/26269))
+- chore(ci): Align Node 27 integration test sharding ([#26375](https://github.com/getsentry/sentry-javascript/pull/26375))
+- chore(ci): Assign 3 PR reviewers via workflow ([#26268](https://github.com/getsentry/sentry-javascript/pull/26268))
+- chore(ci): Assign Junior PRs to their requester and skip them as reviewer ([#26304](https://github.com/getsentry/sentry-javascript/pull/26304))
+- chore(ci): Move reviewer routing out of CODEOWNERS ([#26346](https://github.com/getsentry/sentry-javascript/pull/26346))
+- chore(ci): Never auto-request HazAT as reviewer ([#26353](https://github.com/getsentry/sentry-javascript/pull/26353))
+- chore(ci): Prefer reviewers with fewer recent review requests ([#26407](https://github.com/getsentry/sentry-javascript/pull/26407))
+- chore(ci): Skip busy users when assigning PR reviewers ([#26358](https://github.com/getsentry/sentry-javascript/pull/26358))
+- chore(deno): Note that OTel setup defaulting to on is unintentional ([#26310](https://github.com/getsentry/sentry-javascript/pull/26310))
+- chore(deps): Bump `@sentry/conventions` to 0.33.0 ([#26374](https://github.com/getsentry/sentry-javascript/pull/26374))
+- chore(deps): Record the `node-abort-controller` deprecation in the lockfile ([#26270](https://github.com/getsentry/sentry-javascript/pull/26270))
+- chore(deps): Record the postcss-selector-parser 7.2.0 deprecation in the lockfile ([#26339](https://github.com/getsentry/sentry-javascript/pull/26339))
+- chore(deps): Run yalc via pnpm dlx instead of a root devDependency ([#26318](https://github.com/getsentry/sentry-javascript/pull/26318))
+- chore(deps-dev): Bump @nuxt/schema from 3.21.11 to 4.6.4 ([#26370](https://github.com/getsentry/sentry-javascript/pull/26370))
+- chore(deps-dev): Bump hono from 4.13.11 to 4.13.16 ([#26340](https://github.com/getsentry/sentry-javascript/pull/26340))
+- chore(dev-deps): Replace madge with oxlint import/no-cycle ([#26317](https://github.com/getsentry/sentry-javascript/pull/26317))
+- chore(dev-deps): Replace nodemon with tsx watch ([#26322](https://github.com/getsentry/sentry-javascript/pull/26322))
+- chore(dev-deps): Replace npm-run-all2 with pnpm script selectors ([#26319](https://github.com/getsentry/sentry-javascript/pull/26319))
+- chore: Exempt Sentry packages from release-age checks ([#26274](https://github.com/getsentry/sentry-javascript/pull/26274))
+- chore: Revert add catch-all rule for shared packages in CODEOWNERS ([#25789](https://github.com/getsentry/sentry-javascript/pull/25789)) (#26255)
+- chore: Switch to rolldown ([#20775](https://github.com/getsentry/sentry-javascript/pull/20775))
+- chore: Use What/Why structure in PR template ([#26348](https://github.com/getsentry/sentry-javascript/pull/26348))
+- ci: Cache the Node.js install instead of fetching it in every job ([#26287](https://github.com/getsentry/sentry-javascript/pull/26287))
+- docs(aws-serverless): Use Lambda Event Functions naming in README ([#26354](https://github.com/getsentry/sentry-javascript/pull/26354))
+- docs(browser): Fix `enableLongAnimationFrame` default in JSDoc ([#26256](https://github.com/getsentry/sentry-javascript/pull/26256))
+- feat(deps): Bump @hono/node-server from 2.1.5 to 2.1.7 ([#26331](https://github.com/getsentry/sentry-javascript/pull/26331))
+- feat(deps): Bump node-forge from 1.4.2 to 1.4.3 ([#26267](https://github.com/getsentry/sentry-javascript/pull/26267))
+- fix(ci): separate x64 and ARM64 dependency cache keys ([#26282](https://github.com/getsentry/sentry-javascript/pull/26282))
+- perf(ci): Build CDN bundles in the main build job ([#26379](https://github.com/getsentry/sentry-javascript/pull/26379))
+- perf(ci): Increase integration test sharding ([#26378](https://github.com/getsentry/sentry-javascript/pull/26378))
+- perf(ci): Pack tarballs in the build job ([#26377](https://github.com/getsentry/sentry-javascript/pull/26377))
+- perf(ci): Separate Nuxt production and development E2E jobs ([#26396](https://github.com/getsentry/sentry-javascript/pull/26396))
+- perf(ci): Shard slow Nuxt and Next.js E2E variants ([#26376](https://github.com/getsentry/sentry-javascript/pull/26376))
+- ref(remix): Use the core Server-Timing and shared-cache helpers ([#26326](https://github.com/getsentry/sentry-javascript/pull/26326))
+- ref(server-utils): Extract pi-ai chat span helpers from pi-durable ([#25932](https://github.com/getsentry/sentry-javascript/pull/25932))
+- ref(tanstackstart-react): Forward request options in the server entry example ([#26408](https://github.com/getsentry/sentry-javascript/pull/26408))
+- ref: Share the cache origin helpers of Next.js, Nuxt and SvelteKit ([#26363](https://github.com/getsentry/sentry-javascript/pull/26363))
+- test(astro): Cover server island trace connection in E2E tests ([#26405](https://github.com/getsentry/sentry-javascript/pull/26405))
+- test(astro): Move tunnel e2e tests into a dedicated astro tunnel app ([#26392](https://github.com/getsentry/sentry-javascript/pull/26392))
+- test(cloudflare): Add e2e test for the Cloudflare trace id without tracing ([#25643](https://github.com/getsentry/sentry-javascript/pull/25643))
+- test(cloudflare): Run the SDK on the new module registry ([#26212](https://github.com/getsentry/sentry-javascript/pull/26212))
+- test(e2e): Assert source map stripping for Next.js and TanStack Start ([#26265](https://github.com/getsentry/sentry-javascript/pull/26265))
+- test(e2e): Pin pi to 1.4.0 for node-flue (latest) ([#26237](https://github.com/getsentry/sentry-javascript/pull/26237))
+- test(e2e): Run nestjs-12 on Bun, Deno and Cloudflare ([#26283](https://github.com/getsentry/sentry-javascript/pull/26283))
+- test(e2e): Run OTel SDK E2E apps on SDK v3 with an SDK v2 variant ([#25703](https://github.com/getsentry/sentry-javascript/pull/25703))
+- test(e2e): Trim tracer provider variants down to node-express ([#26385](https://github.com/getsentry/sentry-javascript/pull/26385))
+- test(nextjs): Cover the server request link of a late trace meta tag ([#26357](https://github.com/getsentry/sentry-javascript/pull/26357))
+- test(nextjs): Run the source map upload e2e test on Bun ([#26344](https://github.com/getsentry/sentry-javascript/pull/26344))
+- test(nitro): Move tunnel e2e tests into a dedicated nitro-3-tunnel app ([#26384](https://github.com/getsentry/sentry-javascript/pull/26384))
+- test(nuxt): Add vue-router to Nuxt 5 E2E apps ([#26323](https://github.com/getsentry/sentry-javascript/pull/26323))
+- test(nuxt): Move tunnel e2e tests into dedicated nuxt tunnel apps ([#26393](https://github.com/getsentry/sentry-javascript/pull/26393))
+- test(nuxt): Remove redundant full-suite import compatibility variant ([#26406](https://github.com/getsentry/sentry-javascript/pull/26406))
+- test(react-router): Move tunnel e2e tests into a dedicated react-router-8-tunnel app ([#26388](https://github.com/getsentry/sentry-javascript/pull/26388))
+- test(remix): Move tunnel e2e tests into a dedicated remix-v3-tunnel app ([#26391](https://github.com/getsentry/sentry-javascript/pull/26391))
+- test(scripts): Pass compare fn to sort in assign-reviewers tests ([#26303](https://github.com/getsentry/sentry-javascript/pull/26303))
+- test(solidstart): Move tunnel e2e tests into dedicated solidstart tunnel apps ([#26390](https://github.com/getsentry/sentry-javascript/pull/26390))
+- test(sveltekit): Move tunnel e2e tests into a dedicated sveltekit-3-tunnel app ([#26386](https://github.com/getsentry/sentry-javascript/pull/26386))
+- test(tanstackstart-react): Move tunnel e2e tests into a dedicated tanstackstart-react-tunnel app ([#26389](https://github.com/getsentry/sentry-javascript/pull/26389))
+- test(tanstackstart-react): Run the e2e fixtures on TanStack Start stable ([#26402](https://github.com/getsentry/sentry-javascript/pull/26402))
+
+
+
+Work in this release was contributed by @kunal649, @bardrop, @DomWane, @Vivek1898, @mvanhorn, and @pcbeingused333. Thank you for your contributions!
+
## 11.12.0
### Important Changes
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 79a1beab5799..dfad37a4c049 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -46,13 +46,12 @@ doesn't match the repo, see [Node.js and pnpm Versions](#nodejs-and-pnpm-version
## Building Packages
Since we are using [`TypeScript`](https://www.typescriptlang.org/), you need to transpile the code to JavaScript to be
-able to use it. From the top level of the repo, there are three commands available:
+able to use it. From the top level of the repo, there are two commands available:
- `pnpm run build:dev`, which runs a one-time build of every package
- `pnpm run build:dev:filter `, which runs `pnpm run build:dev` only in projects relevant to the given
package (so, for example, running `pnpm run build:dev:filter @sentry/react` will build the `react` package, all of its
dependencies (`utils`, `core`, `browser`, etc), and all packages which depend on it (currently `gatsby` and `nextjs`))
-- `pnpm run build:dev:watch`, which runs `pnpm run build:dev` in watch mode (recommended)
Note: Due to package incompatibilities between Python versions, building native binaries currently requires a Python
version <3.12.
diff --git a/README.md b/README.md
index 0d82b7f93172..dc97eaf54018 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,7 @@ package. Please refer to the README and instructions of those SDKs for more deta
- [`@sentry/remix`](https://github.com/getsentry/sentry-javascript/tree/master/packages/remix): SDK for Remix
- [`@sentry/tanstackstart-react`](https://github.com/getsentry/sentry-javascript/tree/master/packages/tanstackstart-react): SDK for TanStack Start React
- [`@sentry/aws-serverless`](https://github.com/getsentry/sentry-javascript/tree/master/packages/aws-serverless): SDK
- for AWS Lambda Functions
+ for AWS Lambda Event Functions
- [`@sentry/google-cloud-serverless`](https://github.com/getsentry/sentry-javascript/tree/master/packages/google-cloud-serverless):
SDK for Google Cloud Functions
- [`@sentry/electron`](https://github.com/getsentry/sentry-electron): SDK for Electron with support for native crashes
diff --git a/dev-packages/browser-integration-tests/package.json b/dev-packages/browser-integration-tests/package.json
index 2eeff5ed3129..6809d901a3e2 100644
--- a/dev-packages/browser-integration-tests/package.json
+++ b/dev-packages/browser-integration-tests/package.json
@@ -61,7 +61,7 @@
"@playwright/test": "1.64.1",
"@sentry/browser": "11.12.0",
"@sentry/browser-utils": "11.12.0",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@sentry/core": "11.12.0",
"@sentry/replay": "11.12.0",
"@sentry/replay-canvas": "11.12.0",
diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/captureMessage/subject.js b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessage/subject.js
new file mode 100644
index 000000000000..acf8b119a5e8
--- /dev/null
+++ b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessage/subject.js
@@ -0,0 +1,5 @@
+// Called from a served script so the synthetic stacktrace keeps a frame with a URL. Frames from
+// `page.evaluate` have none, and the SDK's own `captureMessage` frames are stripped.
+window.captureTestMessage = () => {
+ window.Sentry.captureMessage('Some message');
+};
diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/captureMessage/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessage/test.ts
index 90b867c117e3..fd63b05b4207 100644
--- a/dev-packages/browser-integration-tests/suites/replay/errors/captureMessage/test.ts
+++ b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessage/test.ts
@@ -16,7 +16,7 @@ sentryTest(
await waitForReplayRunning(page);
const errorRequestPromise = waitForErrorRequest(page);
- await page.evaluate(() => (window as any).Sentry.captureMessage('Some message'));
+ await page.evaluate(() => (window as any).captureTestMessage());
const event = envelopeRequestParser(await errorRequestPromise);
await forceFlushReplay();
diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/captureMessageAttachStacktrace/subject.js b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessageAttachStacktrace/subject.js
new file mode 100644
index 000000000000..acf8b119a5e8
--- /dev/null
+++ b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessageAttachStacktrace/subject.js
@@ -0,0 +1,5 @@
+// Called from a served script so the synthetic stacktrace keeps a frame with a URL. Frames from
+// `page.evaluate` have none, and the SDK's own `captureMessage` frames are stripped.
+window.captureTestMessage = () => {
+ window.Sentry.captureMessage('Some message');
+};
diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/captureMessageAttachStacktrace/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessageAttachStacktrace/test.ts
index d89371695436..c047f0fcaa7d 100644
--- a/dev-packages/browser-integration-tests/suites/replay/errors/captureMessageAttachStacktrace/test.ts
+++ b/dev-packages/browser-integration-tests/suites/replay/errors/captureMessageAttachStacktrace/test.ts
@@ -22,7 +22,7 @@ sentryTest(
const errorRequestPromise = waitForErrorRequest(page);
const replayRequestPromise = waitForReplayRequest(page, 0);
- await page.evaluate(() => (window as any).Sentry.captureMessage('Some message'));
+ await page.evaluate(() => (window as any).captureTestMessage());
const event = envelopeRequestParser(await errorRequestPromise);
await replayRequestPromise;
diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/subject.js b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/subject.js
new file mode 100644
index 000000000000..24397a4f6f66
--- /dev/null
+++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/subject.js
@@ -0,0 +1,3 @@
+import { simulateCLS } from '../../../../utils/web-vitals/cls.ts';
+
+simulateCLS(0.15).then(() => window.dispatchEvent(new Event('cls-done')));
diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/template.html b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/template.html
new file mode 100644
index 000000000000..10e2e22f7d6a
--- /dev/null
+++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/template.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
Some content
+
+
diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/test.ts
new file mode 100644
index 000000000000..68be3f8f7063
--- /dev/null
+++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-without-array-at/test.ts
@@ -0,0 +1,34 @@
+import { expect } from '@playwright/test';
+import { sentryTest } from '../../../../utils/fixtures';
+import { hidePage, shouldSkipTracingTest } from '../../../../utils/helpers';
+import { getSpanOp, waitForStreamedSpan } from '../../../../utils/spanUtils';
+
+sentryTest.beforeEach(async ({ browserName, page }) => {
+ if (shouldSkipTracingTest() || browserName !== 'chromium') {
+ sentryTest.skip();
+ }
+
+ await page.setViewportSize({ width: 800, height: 1200 });
+});
+
+// Chromium 80-91 is within our supported range and reports layout shifts, but has no `Array.prototype.at`,
+// which web-vitals' CLS code relies on.
+sentryTest('does not throw on layout shifts without Array.prototype.at', async ({ getLocalTestUrl, page }) => {
+ const pageErrors: string[] = [];
+ page.on('pageerror', error => pageErrors.push(error.message));
+
+ await page.addInitScript(() => {
+ // @ts-expect-error - emulating Chromium < 92
+ delete Array.prototype.at;
+ });
+
+ const url = await getLocalTestUrl({ testDir: __dirname });
+ const pageloadSpanPromise = waitForStreamedSpan(page, span => getSpanOp(span) === 'pageload');
+
+ await page.goto(url);
+ await page.evaluate(() => new Promise(resolve => window.addEventListener('cls-done', resolve)));
+ await hidePage(page);
+ await pageloadSpanPromise;
+
+ expect(pageErrors).toEqual([]);
+});
diff --git a/dev-packages/browser-min-version-tests/.gitignore b/dev-packages/browser-min-version-tests/.gitignore
new file mode 100644
index 000000000000..36e1248d6bd9
--- /dev/null
+++ b/dev-packages/browser-min-version-tests/.gitignore
@@ -0,0 +1 @@
+.chromium/
diff --git a/dev-packages/browser-min-version-tests/install-deps.sh b/dev-packages/browser-min-version-tests/install-deps.sh
new file mode 100755
index 000000000000..8316317a7d05
--- /dev/null
+++ b/dev-packages/browser-min-version-tests/install-deps.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Old Chromium links against libXss, which current runner images don't ship. Installing from the image's
+# package lists is fast; only refresh them when they are too stale to resolve the package.
+set -eu
+
+if ! sudo apt-get install -y --no-install-recommends libxss1; then
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends libxss1
+fi
diff --git a/dev-packages/browser-min-version-tests/package.json b/dev-packages/browser-min-version-tests/package.json
new file mode 100644
index 000000000000..172040f165b6
--- /dev/null
+++ b/dev-packages/browser-min-version-tests/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "@sentry-internal/browser-min-version-tests",
+ "version": "11.12.0",
+ "license": "MIT",
+ "private": true,
+ "type": "module",
+ "engines": {
+ "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0"
+ },
+ "devDependencies": {
+ "@sentry-internal/test-utils": "11.12.0"
+ }
+}
diff --git a/dev-packages/browser-min-version-tests/page.html b/dev-packages/browser-min-version-tests/page.html
new file mode 100644
index 000000000000..c918731ca689
--- /dev/null
+++ b/dev-packages/browser-min-version-tests/page.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
Largest contentful paint
+
Shifting
+
+
+
+
diff --git a/dev-packages/browser-min-version-tests/run.mjs b/dev-packages/browser-min-version-tests/run.mjs
new file mode 100644
index 000000000000..64d3b686010c
--- /dev/null
+++ b/dev-packages/browser-min-version-tests/run.mjs
@@ -0,0 +1,275 @@
+// Loads the CDN bundles in the oldest Chromium we support and checks that the web vitals it can
+// measure are sent, and that nothing throws. Playwright only drives the Chromium it ships with, so
+// this talks to the browser over the DevTools protocol directly. Run it after `pnpm build:bundle` in
+// `packages/browser`.
+import { execFileSync, spawn } from 'node:child_process';
+import { createHash } from 'node:crypto';
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { createServer } from 'node:http';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { CDPClient, createBasicSentryServer, getSpanOp } from '@sentry-internal/test-utils';
+
+// Chromium 80.0.3987.0, the minimum Chrome version in our supported browsers docs.
+const CHROMIUM_REVISION = '722234';
+const CHROMIUM_ZIP_SHA256 = '2a7f1d1cf4fd933f4090739667f86b52187431a5a22e5f33a4a2be158d4574dc';
+const DIR = path.dirname(fileURLToPath(import.meta.url));
+const CHROMIUM_DIR = path.join(DIR, '.chromium', CHROMIUM_REVISION);
+const CHROME = path.join(CHROMIUM_DIR, 'chrome-linux', 'chrome');
+const BUNDLES_DIR = path.join(DIR, '../../packages/browser/build/bundles');
+const BUNDLES = [
+ 'bundle.tracing.min.js',
+ // The debug build logs errors the SDK catches internally, which would otherwise go unnoticed.
+ 'bundle.tracing.replay.feedback.logs.metrics.debug.min.js',
+];
+const PAGE = readFileSync(path.join(DIR, 'page.html'), 'utf8');
+
+// What Chromium 80 can report. CLS is skipped there because web-vitals' CLS code needs
+// `Array.prototype.at` (Chromium 92), and INP needs `PerformanceEventTiming.interactionId` (Chromium 96).
+const EXPECTED_PAGELOAD_VITALS = ['fcp', 'fp', 'ttfb'];
+const UNEXPECTED_SPAN_OPS = ['ui.webvital.cls', 'ui.interaction.click'];
+
+async function ensureChromium() {
+ if (existsSync(CHROME)) {
+ return;
+ }
+ const url = `https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/${CHROMIUM_REVISION}/chrome-linux.zip`;
+ const response = await fetch(url, { signal: AbortSignal.timeout(120_000) });
+ if (!response.ok) {
+ throw new Error(`Downloading Chromium failed: ${response.status} ${url}`);
+ }
+ const data = Buffer.from(await response.arrayBuffer());
+ const sha256 = createHash('sha256').update(data).digest('hex');
+ if (sha256 !== CHROMIUM_ZIP_SHA256) {
+ throw new Error(`Chromium download has SHA-256 ${sha256}, expected ${CHROMIUM_ZIP_SHA256}`);
+ }
+ mkdirSync(CHROMIUM_DIR, { recursive: true });
+ const zip = `${CHROMIUM_DIR}.zip`;
+ writeFileSync(zip, data);
+ execFileSync('unzip', ['-q', zip, '-d', CHROMIUM_DIR]);
+ rmSync(zip);
+}
+
+// The page and the DSN are on different ports, so envelopes are sent cross-origin like they are to sentry.io.
+function startPageServer(bundlePath, sentryPort) {
+ const page = PAGE.replace('__DSN__', `http://public@localhost:${sentryPort}/1337`);
+ const server = createServer((req, res) => {
+ if (req.url === '/bundle.js') {
+ res.setHeader('content-type', 'text/javascript');
+ res.end(readFileSync(bundlePath));
+ return;
+ }
+ res.setHeader('content-type', 'text/html');
+ res.end(page);
+ });
+ return new Promise(resolve => server.listen(0, '127.0.0.1', () => resolve(server)));
+}
+
+function launchChrome(userDataDir) {
+ const chrome = spawn(CHROME, [
+ '--headless',
+ '--no-sandbox',
+ '--disable-gpu',
+ '--remote-debugging-port=0',
+ '--window-size=800,1200',
+ `--user-data-dir=${userDataDir}`,
+ 'about:blank',
+ ]);
+ const port = new Promise((resolve, reject) => {
+ let stderr = '';
+ chrome.stderr.on('data', chunk => {
+ stderr += chunk;
+ const match = stderr.match(/DevTools listening on ws:\/\/127\.0\.0\.1:(\d+)\//);
+ if (match) {
+ resolve(match[1]);
+ }
+ });
+ chrome.on('exit', code => reject(new Error(`Chromium exited with ${code}:\n${stderr}`)));
+ });
+ return { chrome, port };
+}
+
+async function connect(port) {
+ // The DevTools server can come up before the initial page target exists.
+ let page;
+ for (let attempt = 0; !page && attempt < 50; attempt++) {
+ const targets = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json();
+ page = targets.find(target => target.type === 'page');
+ if (!page) {
+ await new Promise(resolve => setTimeout(resolve, 100));
+ }
+ }
+ if (!page) {
+ throw new Error('Chromium has no page target');
+ }
+ const cdp = new CDPClient({ url: page.webSocketDebuggerUrl, retries: 1 });
+ await cdp.connect();
+ return cdp;
+}
+
+function waitForEvent(cdp, method) {
+ return new Promise(resolve => {
+ const off = cdp.on(method, () => {
+ off();
+ resolve();
+ });
+ });
+}
+
+async function evaluate(cdp, expression) {
+ const { result, exceptionDetails } = await cdp.send('Runtime.evaluate', {
+ expression,
+ awaitPromise: true,
+ returnByValue: true,
+ });
+ if (exceptionDetails) {
+ throw new Error(`Evaluating failed: ${exceptionDetails.exception?.description ?? exceptionDetails.text}`);
+ }
+ return result.value;
+}
+
+function collectItems(spans, events) {
+ return ([, items]) => {
+ for (const [header, payload] of items) {
+ if (header.type === 'span') {
+ spans.push(...payload.items);
+ } else if (header.type === 'event') {
+ events.push(payload);
+ }
+ }
+ };
+}
+
+const isPageload = span => span.is_segment && getSpanOp(span) === 'pageload';
+
+async function runBundle(bundle) {
+ const spans = [];
+ const events = [];
+ const errors = [];
+ const [sentryPort, closeSentryServer] = await createBasicSentryServer(collectItems(spans, events));
+ const server = await startPageServer(path.join(BUNDLES_DIR, bundle), sentryPort);
+ const userDataDir = mkdtempSync(path.join(tmpdir(), 'chromium-profile-'));
+ const { chrome, port } = launchChrome(userDataDir);
+ let cdp;
+
+ try {
+ cdp = await connect(await port);
+ cdp.on('Runtime.exceptionThrown', ({ exceptionDetails }) => {
+ errors.push(exceptionDetails.exception?.description ?? exceptionDetails.text);
+ });
+ cdp.on('Runtime.consoleAPICalled', ({ type, args }) => {
+ if (type === 'error') {
+ errors.push(args.map(arg => arg.value ?? arg.description).join(' '));
+ }
+ });
+ cdp.on('Log.entryAdded', ({ entry }) => {
+ if (entry.level === 'error') {
+ errors.push(entry.text);
+ }
+ });
+ await Promise.all([cdp.send('Runtime.enable'), cdp.send('Log.enable'), cdp.send('Page.enable')]);
+
+ const loaded = waitForEvent(cdp, 'Page.loadEventFired');
+ await cdp.send('Page.navigate', { url: `http://127.0.0.1:${server.address().port}/` });
+ await loaded;
+
+ // Layout shifts, then a click: shifts within 500ms after an input don't count towards CLS.
+ await evaluate(
+ cdp,
+ `(async () => {
+ const element = document.getElementById('shift');
+ for (let i = 1; i <= 10; i++) {
+ element.style.top = 200 + i * 40 + 'px';
+ await new Promise(resolve => setTimeout(resolve, 50));
+ }
+ })()`,
+ );
+ const { x, y } = await evaluate(
+ cdp,
+ `(() => {
+ const rect = document.getElementById('button').getBoundingClientRect();
+ return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
+ })()`,
+ );
+ for (const type of ['mousePressed', 'mouseReleased']) {
+ await cdp.send('Input.dispatchMouseEvent', { type, x, y, button: 'left', clickCount: 1 });
+ }
+ await new Promise(resolve => setTimeout(resolve, 300));
+
+ // Without these, the checks that CLS and INP are not sent would pass without testing anything.
+ const { layoutShifts, clicked } = await evaluate(
+ cdp,
+ `new Promise(resolve => {
+ const done = layoutShifts => resolve({ layoutShifts, clicked: document.getElementById('button').dataset.clicked === 'true' });
+ new PerformanceObserver(list => done(list.getEntries().length)).observe({ type: 'layout-shift', buffered: true });
+ setTimeout(() => done(0), 500);
+ })`,
+ );
+ if (!layoutShifts || !clicked) {
+ throw new Error(`Page did not shift (${layoutShifts} layout shifts) or was not clicked (${clicked})`);
+ }
+
+ // Hiding the page is what makes the SDK finalize LCP and CLS.
+ await evaluate(
+ cdp,
+ `(() => {
+ Object.defineProperty(document, 'visibilityState', { configurable: true, get: () => 'hidden' });
+ document.dispatchEvent(new Event('visibilitychange'));
+ })()`,
+ );
+ // The pageload span, which carries FCP, FP and TTFB, ends once the page has been idle for a second.
+ const deadline = Date.now() + 10_000;
+ while (!spans.some(isPageload) && Date.now() < deadline) {
+ await new Promise(resolve => setTimeout(resolve, 100));
+ }
+ } finally {
+ await cdp?.close();
+ chrome.kill();
+ server.close();
+ closeSentryServer();
+ rmSync(userDataDir, { recursive: true, force: true });
+ }
+
+ const pageload = spans.find(isPageload);
+ const ops = new Set(spans.map(getSpanOp));
+ const failures = [...new Set(errors)].map(error => `page error: ${error}`);
+
+ for (const event of events) {
+ failures.push(`error event sent: ${event.exception?.values?.[0]?.value ?? event.message}`);
+ }
+ if (!pageload) {
+ failures.push('no pageload span sent');
+ } else {
+ if (!pageload.attributes['user_agent.original']?.value.includes('Chrome/80.')) {
+ failures.push(`not running in Chrome 80: ${pageload.attributes['user_agent.original']?.value}`);
+ }
+ for (const vital of EXPECTED_PAGELOAD_VITALS) {
+ if (typeof pageload.attributes[`browser.web_vital.${vital}.value`]?.value !== 'number') {
+ failures.push(`pageload span has no ${vital.toUpperCase()}`);
+ }
+ }
+ }
+ const lcp = spans.find(span => getSpanOp(span) === 'ui.webvital.lcp');
+ if (typeof lcp?.attributes['browser.web_vital.lcp.value']?.value !== 'number') {
+ failures.push('no LCP span sent');
+ }
+ for (const unexpected of UNEXPECTED_SPAN_OPS) {
+ if (ops.has(unexpected)) {
+ failures.push(`unexpected ${unexpected} span sent`);
+ }
+ }
+
+ return failures;
+}
+
+await ensureChromium();
+
+const results = await Promise.all(BUNDLES.map(runBundle));
+results.forEach((failures, index) => {
+ // eslint-disable-next-line no-console
+ console.log(
+ `${failures.length ? '✘' : '✓'} ${BUNDLES[index]}${failures.map(failure => `\n ${failure}`).join('')}`,
+ );
+});
+process.exitCode = results.some(failures => failures.length) ? 1 : 0;
diff --git a/dev-packages/bun-integration-tests/node-suites/excludes.ts b/dev-packages/bun-integration-tests/node-suites/excludes.ts
index 60d47967bd65..ff7e526ad3db 100644
--- a/dev-packages/bun-integration-tests/node-suites/excludes.ts
+++ b/dev-packages/bun-integration-tests/node-suites/excludes.ts
@@ -120,6 +120,7 @@ export const NO_AUTO_INSTRUMENTATION = [
'suites/tracing/openai/v6/test.ts',
'suites/tracing/openai/v7/test.ts',
'suites/tracing/orchestrion-lazy-registration/test.ts',
+ 'suites/tracing/pi-ai/test.ts',
'suites/tracing/pi-durable/test.ts',
'suites/tracing/postgres/test.ts',
'suites/tracing/postgresjs/test.ts',
diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic-cjs.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic-cjs.test.ts
index e91fb5ed133b..f07edbcb8c58 100644
--- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic-cjs.test.ts
+++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic-cjs.test.ts
@@ -35,6 +35,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
"sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"],
["release","set-commits","CURRENT_SHA","--auto"],
["release","finalize","CURRENT_SHA"],
+ ["sourcemap","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path"],
",
}
`);
diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic.test.ts
index e91fb5ed133b..f07edbcb8c58 100644
--- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic.test.ts
+++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/basic.test.ts
@@ -35,6 +35,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
"sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"],
["release","set-commits","CURRENT_SHA","--auto"],
["release","finalize","CURRENT_SHA"],
+ ["sourcemap","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path"],
",
}
`);
diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/release-disabled.test.ts
index 64fdb039b963..7aac92da1976 100644
--- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/release-disabled.test.ts
+++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/release-disabled.test.ts
@@ -34,6 +34,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
",
"sentry-cli-mock.json": "["release","set-commits","CURRENT_SHA","--auto"],
["release","finalize","CURRENT_SHA"],
+ ["sourcemap","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path"],
",
}
`);
diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-assets-auto.config.js b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-assets-auto.config.js
new file mode 100644
index 000000000000..588483bf6eea
--- /dev/null
+++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-assets-auto.config.js
@@ -0,0 +1,14 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/bundler-plugins/esbuild";
+import { sentryConfig } from "../configs/sourcemaps-assets-auto.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/entry1.js", "./src/entry2.js"],
+ bundle: true,
+ outdir: "./out/sourcemaps-assets-auto",
+ minify: false,
+ format: "esm",
+ splitting: true,
+ chunkNames: "[name]",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-assets-auto.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-assets-auto.test.ts
new file mode 100644
index 000000000000..4751e8acc361
--- /dev/null
+++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-assets-auto.test.ts
@@ -0,0 +1,33 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles }) => {
+ runBundler({ SENTRY_TEST_RECORD_UPLOADED_SOURCES: "1" });
+ const files = readOutputFiles();
+
+ expect(Object.keys(files).sort()).toMatchInlineSnapshot(`
+ [
+ "chunk.js",
+ "entry1.js",
+ "entry2.js",
+ "sentry-cli-mock.json",
+ "sentry-uploaded-sources.json",
+ ]
+ `);
+ expect(JSON.parse(files["sentry-uploaded-sources.json"]!)).toMatchInlineSnapshot(`
+ [
+ [
+ "sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000",
+ "../../src/entry1.js",
+ "../../src/entry1.js",
+ ],
+ ]
+ `);
+ expect(files["sentry-cli-mock.json"]).toMatchInlineSnapshot(`
+ "["release","create","CURRENT_SHA","--project","fake-project"],
+ ["release","set-commits","CURRENT_SHA","--auto"],
+ ["release","finalize","CURRENT_SHA"],
+ ["sourcemap","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path"],
+ "
+ `);
+});
diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-ignore-auto.config.js b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-ignore-auto.config.js
new file mode 100644
index 000000000000..8737a7c03287
--- /dev/null
+++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-ignore-auto.config.js
@@ -0,0 +1,14 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/bundler-plugins/esbuild";
+import { sentryConfig } from "../configs/sourcemaps-ignore-auto.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/entry1.js", "./src/entry2.js"],
+ bundle: true,
+ outdir: "./out/sourcemaps-ignore-auto",
+ minify: false,
+ format: "esm",
+ splitting: true,
+ chunkNames: "[name]",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-ignore-auto.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-ignore-auto.test.ts
new file mode 100644
index 000000000000..4751e8acc361
--- /dev/null
+++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/sourcemaps-ignore-auto.test.ts
@@ -0,0 +1,33 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles }) => {
+ runBundler({ SENTRY_TEST_RECORD_UPLOADED_SOURCES: "1" });
+ const files = readOutputFiles();
+
+ expect(Object.keys(files).sort()).toMatchInlineSnapshot(`
+ [
+ "chunk.js",
+ "entry1.js",
+ "entry2.js",
+ "sentry-cli-mock.json",
+ "sentry-uploaded-sources.json",
+ ]
+ `);
+ expect(JSON.parse(files["sentry-uploaded-sources.json"]!)).toMatchInlineSnapshot(`
+ [
+ [
+ "sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000",
+ "../../src/entry1.js",
+ "../../src/entry1.js",
+ ],
+ ]
+ `);
+ expect(files["sentry-cli-mock.json"]).toMatchInlineSnapshot(`
+ "["release","create","CURRENT_SHA","--project","fake-project"],
+ ["release","set-commits","CURRENT_SHA","--auto"],
+ ["release","finalize","CURRENT_SHA"],
+ ["sourcemap","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path"],
+ "
+ `);
+});
diff --git a/dev-packages/bundler-plugin-integration-tests/package.json b/dev-packages/bundler-plugin-integration-tests/package.json
index 9c61edd0b2f5..9f42dcc5fd21 100644
--- a/dev-packages/bundler-plugin-integration-tests/package.json
+++ b/dev-packages/bundler-plugin-integration-tests/package.json
@@ -6,8 +6,8 @@
"scripts": {
"test": "node setup.mjs && vitest run --pool threads --test-timeout=10000",
"check:types": "tsc --project ./tsconfig.json --noEmit",
- "clean": "run-s clean:build",
- "clean:all": "run-p clean clean:deps",
+ "clean": "pnpm run clean:build",
+ "clean:all": "pnpm run \"/^(clean|clean:deps)$/\"",
"clean:build": "node ../../scripts/rm.mjs ./fixtures/*/out",
"clean:deps": "node ../../scripts/rm.mjs node_modules"
},
diff --git a/dev-packages/bundler-tests/tests/runtime-entries.test.ts b/dev-packages/bundler-tests/tests/runtime-entries.test.ts
index 156102cc6765..90dcb2833f8c 100644
--- a/dev-packages/bundler-tests/tests/runtime-entries.test.ts
+++ b/dev-packages/bundler-tests/tests/runtime-entries.test.ts
@@ -17,24 +17,33 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT_DIR = path.join(__dirname, '../../..');
const FIXTURE_DIR = path.join(__dirname, '..', 'dist', 'runtime-entries');
+/** Third-party build tools. No Sentry code is reachable through them. */
+const BUILD_TOOL_PATTERNS: RegExp[] = [
+ /(^|\/)node_modules\/(vite|webpack|rollup|esbuild|oxc-parser)\//,
+ /(^|\/)node_modules\/@(babel|rollup|oxc-parser)\//,
+ /\.wasm$/,
+];
+
const BUILD_TIME_PATTERNS: RegExp[] = [
/(^|\/)packages\/bundler-plugins\//,
/(^|\/)node_modules\/@sentry\/bundler-plugins(\/|$)/,
/(^|\/)packages\/server-utils\/build\/[^/]+\/orchestrion\/bundler\//,
- /(^|\/)node_modules\/(vite|webpack|rollup|esbuild|oxc-parser)\//,
- /(^|\/)node_modules\/@(babel|rollup|oxc-parser)\//,
- /\.wasm$/,
+ ...BUILD_TOOL_PATTERNS,
+];
+
+const RUNTIME_INJECTION_PATTERNS: RegExp[] = [
+ /(^|\/)packages\/server-runtime-injection\//,
+ /(^|\/)node_modules\/@sentry\/server-runtime-injection(\/|$)/,
];
-const KNOWN_VIOLATIONS = new Set([
- // These root entries also re-export config-time code (`sentryAstro`,
- // `withSentry`). They must keep it until v12 for backwards compatibility.
- '@sentry/astro',
- '@sentry/solidstart',
- // Remix 3 has no bundler. Its asset server runs the orchestrion
- // transform on browser modules at request time.
- '@sentry/remix/v3',
- '@sentry/remix/v3/node',
+// These config entries import the `@sentry/node` root, which installs
+// runtime injection when a client is made.
+const KNOWN_RUNTIME_INJECTION_VIOLATIONS = new Set([
+ // `getSentryRelease`
+ '@sentry/nextjs/config',
+ '@sentry/sveltekit/vite',
+ // `setupSentryNitroModule`, through the `@sentry/nitro` root
+ '@sentry/solidstart/vite',
]);
type Format = 'esm' | 'cjs';
@@ -43,6 +52,8 @@ interface Case {
specifier: string;
conditions: string[];
formats: Format[];
+ /** The entry reaches build-time tooling on purpose. Drop this when the test fails. */
+ knownViolation?: true;
}
const NODE = ['node'];
@@ -81,7 +92,11 @@ const CASES: Case[] = [
{ specifier: '@sentry/sveltekit', conditions: ['worker'], formats: BOTH },
{ specifier: '@sentry/sveltekit/opentelemetry-api', conditions: NODE, formats: BOTH },
- { specifier: '@sentry/astro', conditions: NODE, formats: BOTH },
+ // The Node root entry also re-exports config-time code (`sentryAstro`). It must keep it until v12
+ // for backwards compatibility.
+ { specifier: '@sentry/astro', conditions: NODE, formats: BOTH, knownViolation: true },
+ { specifier: '@sentry/astro', conditions: WORKERD, formats: BOTH },
+ { specifier: '@sentry/astro', conditions: ['worker'], formats: BOTH },
{ specifier: '@sentry/astro/middleware', conditions: NODE, formats: BOTH },
{ specifier: '@sentry/astro/import', conditions: NODE, formats: ESM },
@@ -93,10 +108,14 @@ const CASES: Case[] = [
{ specifier: '@sentry/remix', conditions: ['worker'], formats: BOTH },
{ specifier: '@sentry/remix/cloudflare', conditions: WORKERD, formats: BOTH },
{ specifier: '@sentry/remix/import', conditions: NODE, formats: ESM },
- { specifier: '@sentry/remix/v3', conditions: NODE, formats: ESM },
- { specifier: '@sentry/remix/v3/node', conditions: NODE, formats: ESM },
+ // Remix 3 has no bundler. Its asset server runs the orchestrion transform on browser modules at
+ // request time.
+ { specifier: '@sentry/remix/v3', conditions: NODE, formats: ESM, knownViolation: true },
+ { specifier: '@sentry/remix/v3/node', conditions: NODE, formats: ESM, knownViolation: true },
- { specifier: '@sentry/solidstart', conditions: NODE, formats: BOTH },
+ // The root entry also re-exports config-time code (`withSentry`). It must keep it until v12 for
+ // backwards compatibility.
+ { specifier: '@sentry/solidstart', conditions: NODE, formats: BOTH, knownViolation: true },
{ specifier: '@sentry/tanstackstart-react', conditions: NODE, formats: BOTH },
{ specifier: '@sentry/tanstackstart-react/import', conditions: NODE, formats: ESM },
@@ -138,8 +157,8 @@ function writeFixture(specifier: string, conditions: string[], format: Format):
return file;
}
-function isBuildTime(file: string): boolean {
- return BUILD_TIME_PATTERNS.some(pattern => pattern.test(file));
+function matches(file: string, patterns: RegExp[]): boolean {
+ return patterns.some(pattern => pattern.test(file));
}
type Reasons = Awaited>['reasons'];
@@ -173,10 +192,10 @@ function importChain(reasons: Reasons, entry: string, file: string): string[] {
}
/**
- * Each place where a runtime module imports a build-time module, as the
- * import chain from the entry.
+ * Each place where a module imports a module that matches `targets`, as
+ * the import chain from the entry.
*/
-async function findBuildTimeImports(fixture: string, conditions: string[]): Promise {
+async function findImports(fixture: string, conditions: string[], targets: RegExp[]): Promise {
const imports: [importer: string, file: string][] = [];
const { fileList, reasons } = await nodeFileTrace([fixture], {
@@ -186,14 +205,14 @@ async function findBuildTimeImports(fixture: string, conditions: string[]): Prom
// A dynamic `fs` path in config code makes nft glob the whole repo.
// That is slow and finds user files, not package code.
analysis: { emitGlobs: false },
- // Stop at the first build-time module, instead of tracing all of Vite
- // or Babel. `.wasm` files are assets, so they stay in the trace with
- // their importer.
- ignore: file => isBuildTime(file) && !file.endsWith('.wasm'),
+ // Stop at the first target, and do not trace all of Vite or Babel.
+ // `.wasm` files are assets, so they stay in the trace with their
+ // importer.
+ ignore: file => matches(file, [...targets, ...BUILD_TOOL_PATTERNS]) && !file.endsWith('.wasm'),
async resolve(id, parent, job, cjsResolve) {
const resolved = await resolve(id, parent, job, cjsResolve);
for (const file of [resolved].flat()) {
- if (isBuildTime(file)) {
+ if (matches(file, targets)) {
imports.push([path.relative(ROOT_DIR, parent), path.relative(ROOT_DIR, file)]);
}
}
@@ -202,7 +221,7 @@ async function findBuildTimeImports(fixture: string, conditions: string[]): Prom
});
for (const file of fileList) {
- if (file.endsWith('.wasm')) {
+ if (file.endsWith('.wasm') && matches(file, targets)) {
for (const parent of reasons.get(file)?.parents ?? []) {
imports.push([parent, file]);
}
@@ -217,19 +236,26 @@ async function findBuildTimeImports(fixture: string, conditions: string[]): Prom
}
describe('server runtime entries do not reach build-time tooling', () => {
- for (const { specifier, conditions, formats } of CASES) {
+ for (const { specifier, conditions, formats, knownViolation } of CASES) {
for (const format of formats) {
const name = `${specifier} (${format}, conditions: ${conditions.join(', ')})`;
- if (KNOWN_VIOLATIONS.has(specifier)) {
+ if (knownViolation) {
test(`${name} is a known violation`, async () => {
- const violations = await findBuildTimeImports(writeFixture(specifier, conditions, format), conditions);
- // Remove the entry from KNOWN_VIOLATIONS when this fails.
+ const violations = await findImports(
+ writeFixture(specifier, conditions, format),
+ conditions,
+ BUILD_TIME_PATTERNS,
+ );
expect(violations).not.toEqual([]);
});
} else {
test(name, async () => {
- const violations = await findBuildTimeImports(writeFixture(specifier, conditions, format), conditions);
+ const violations = await findImports(
+ writeFixture(specifier, conditions, format),
+ conditions,
+ BUILD_TIME_PATTERNS,
+ );
expect(violations).toEqual([]);
});
}
@@ -241,13 +267,38 @@ describe('build-time entries reach build-time tooling', () => {
for (const { specifier, conditions, formats } of BUILD_TIME_CASES) {
for (const format of formats) {
test(`${specifier} (${format}, conditions: ${conditions.join(', ')})`, async () => {
- const violations = await findBuildTimeImports(writeFixture(specifier, conditions, format), conditions);
+ const violations = await findImports(
+ writeFixture(specifier, conditions, format),
+ conditions,
+ BUILD_TIME_PATTERNS,
+ );
expect(violations).not.toEqual([]);
});
}
}
});
+describe('build-time entries do not reach runtime injection', () => {
+ for (const { specifier, conditions, formats } of BUILD_TIME_CASES) {
+ for (const format of formats) {
+ const name = `${specifier} (${format}, conditions: ${conditions.join(', ')})`;
+ const find = (): Promise =>
+ findImports(writeFixture(specifier, conditions, format), conditions, RUNTIME_INJECTION_PATTERNS);
+
+ if (KNOWN_RUNTIME_INJECTION_VIOLATIONS.has(specifier)) {
+ test(`${name} is a known violation`, async () => {
+ // Remove the entry from KNOWN_RUNTIME_INJECTION_VIOLATIONS when this fails.
+ expect(await find()).not.toEqual([]);
+ });
+ } else {
+ test(name, async () => {
+ expect(await find()).toEqual([]);
+ });
+ }
+ }
+ }
+});
+
test('every export of a tested package is classified', () => {
const classified = new Set([...CASES, ...BUILD_TIME_CASES].map(({ specifier }) => specifier));
for (const specifier of CLIENT_ENTRIES) {
diff --git a/dev-packages/bundler-tests/tests/startup.test.ts b/dev-packages/bundler-tests/tests/startup.test.ts
new file mode 100644
index 000000000000..2a94028e2663
--- /dev/null
+++ b/dev-packages/bundler-tests/tests/startup.test.ts
@@ -0,0 +1,69 @@
+import { describe, expect, test } from 'vitest';
+import { execFileSync } from 'node:child_process';
+import * as fs from 'node:fs';
+import * as path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+/**
+ * Node resolves, reads and evaluates each published file on its own, so
+ * the number of files that `@sentry/node` loads sets most of its startup
+ * cost. Our CJS builds publish flat entry files with a few shared chunks.
+ * The ESM builds keep one file per module, because bundlers use them and
+ * drop unused files. A count is stable in CI, where a timing is not.
+ */
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE_DIR = path.join(__dirname, '..', 'dist', 'startup');
+
+// One entry file and its shared chunks.
+const MAX_FILES_PER_PACKAGE = 10;
+
+const COUNTER = `import { writeSync } from 'node:fs';
+import { registerHooks } from 'node:module';
+const files = new Set();
+registerHooks({
+ load(url, context, nextLoad) {
+ if (url.startsWith('file:')) files.add(url);
+ return nextLoad(url, context);
+ },
+});
+// A pipe write from an exit handler must be sync, or Node cuts it off.
+process.on('exit', () => writeSync(1, JSON.stringify([...files])));
+`;
+
+function loadedFiles(specifier: string): string[] {
+ fs.mkdirSync(FIXTURE_DIR, { recursive: true });
+ const counter = path.join(FIXTURE_DIR, 'counter.mjs');
+ fs.writeFileSync(counter, COUNTER);
+ const fixture = path.join(FIXTURE_DIR, `${specifier.replace(/[@/]/g, '_')}.cjs`);
+ fs.writeFileSync(fixture, `require('${specifier}');\n`);
+
+ const output = execFileSync(process.execPath, ['--import', counter, fixture], { encoding: 'utf8' });
+ return (JSON.parse(output) as string[]).map(url => fileURLToPath(url)).filter(file => file !== fixture);
+}
+
+/** The package that `file` belongs to, for workspace and installed packages. */
+function packageOf(file: string): string {
+ const installed = file.split('/node_modules/').at(-1) as string;
+ if (installed !== file) {
+ const [scope, name] = installed.split('/');
+ return scope?.startsWith('@') ? `${scope}/${name}` : (scope as string);
+ }
+ const workspace = file.match(/\/packages\/([^/]+)\//);
+ return workspace ? `@sentry/${workspace[1]}` : file;
+}
+
+describe('@sentry/node startup', () => {
+ test(`each Sentry package loads at most ${MAX_FILES_PER_PACKAGE} files`, () => {
+ const counts: Record = {};
+ for (const file of loadedFiles('@sentry/node')) {
+ const pkg = packageOf(file);
+ if (pkg.startsWith('@sentry/')) {
+ counts[pkg] = (counts[pkg] ?? 0) + 1;
+ }
+ }
+
+ const tooMany = Object.fromEntries(Object.entries(counts).filter(([, count]) => count > MAX_FILES_PER_PACKAGE));
+ expect(tooMany).toEqual({});
+ });
+});
diff --git a/dev-packages/cloudflare-integration-tests/expect.ts b/dev-packages/cloudflare-integration-tests/expect.ts
index 71eb5c9963c4..5d7699e70367 100644
--- a/dev-packages/cloudflare-integration-tests/expect.ts
+++ b/dev-packages/cloudflare-integration-tests/expect.ts
@@ -1,6 +1,7 @@
import type { Contexts, Envelope, Event, SdkInfo } from '@sentry/core';
import { SDK_VERSION } from '@sentry/core';
import { expect } from 'vitest';
+import { supports } from './runtime';
export const UUID_MATCHER = expect.stringMatching(/^[\da-f]{32}$/);
export const UUID_V4_MATCHER = expect.stringMatching(
@@ -39,6 +40,7 @@ function defaultContexts(eventContexts: Contexts = {}): Contexts {
trace: {
trace_id: UUID_MATCHER,
span_id: SHORT_UUID_MATCHER,
+ parent_span_id: supports({ minWorkerd: '1.20261009.1' }) ? SHORT_UUID_MATCHER : undefined,
},
cloud_resource: { 'cloud.provider': 'cloudflare' },
culture: { timezone: expect.any(String) },
diff --git a/dev-packages/cloudflare-integration-tests/package.json b/dev-packages/cloudflare-integration-tests/package.json
index 869263da78bb..a1ddbfeaaac4 100644
--- a/dev-packages/cloudflare-integration-tests/package.json
+++ b/dev-packages/cloudflare-integration-tests/package.json
@@ -28,7 +28,7 @@
"@prisma/client": "6.15.0",
"@sentry-internal/test-utils": "11.12.0",
"@sentry/cloudflare": "11.12.0",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@sentry/core": "11.12.0",
"@sentry/hono": "11.12.0",
"ai": "^6.0.0",
diff --git a/dev-packages/cloudflare-integration-tests/runtime.ts b/dev-packages/cloudflare-integration-tests/runtime.ts
new file mode 100644
index 000000000000..9f175f0c94be
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/runtime.ts
@@ -0,0 +1,31 @@
+import { parseSemver } from '@sentry/core';
+import { createRequire } from 'module';
+
+// `wrangler dev` runs the workerd that its own miniflare depends on.
+const wranglerRequire = createRequire(createRequire(__filename).resolve('wrangler/package.json'));
+const miniflareRequire = createRequire(wranglerRequire.resolve('miniflare/package.json'));
+const WORKERD_VERSION = parseSemver((miniflareRequire('workerd/package.json') as { version: string }).version);
+
+export type Requirements = {
+ /** Lowest workerd version that runs the tests, for example `1.20261009.1`. */
+ minWorkerd?: string;
+};
+
+/**
+ * Whether the workerd that runs the Workers meets the requirements of the tests, for use in `it.runIf` and
+ * `it.skipIf`. The pinned wrangler of the required CI job runs an older workerd than the latest wrangler of the
+ * optional CI job.
+ */
+export function supports({ minWorkerd }: Requirements): boolean {
+ if (!minWorkerd) {
+ return true;
+ }
+
+ const required = parseSemver(minWorkerd);
+ const difference =
+ (WORKERD_VERSION.major || 0) - (required.major || 0) ||
+ (WORKERD_VERSION.minor || 0) - (required.minor || 0) ||
+ (WORKERD_VERSION.patch || 0) - (required.patch || 0);
+
+ return difference >= 0;
+}
diff --git a/dev-packages/cloudflare-integration-tests/suites/hono-sdk/test.ts b/dev-packages/cloudflare-integration-tests/suites/hono-sdk/test.ts
index 33ba266ed7cc..ebf929489edd 100644
--- a/dev-packages/cloudflare-integration-tests/suites/hono-sdk/test.ts
+++ b/dev-packages/cloudflare-integration-tests/suites/hono-sdk/test.ts
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest';
-import { eventEnvelope } from '../../expect';
+import { eventEnvelope, SHORT_UUID_MATCHER, UUID_MATCHER } from '../../expect';
import { createRunner } from '../../runner';
import { getSpanOp, getSpansFromEnvelope } from '../../spanUtils';
@@ -28,6 +28,12 @@ it('Hono app captures parametrized errors (Hono SDK)', async ({ signal }) => {
method: 'GET',
url: expect.stringContaining('/error/param-123'),
},
+ contexts: {
+ trace: {
+ trace_id: UUID_MATCHER,
+ span_id: SHORT_UUID_MATCHER,
+ },
+ },
breadcrumbs: [
{
timestamp: expect.any(Number),
diff --git a/dev-packages/cloudflare-integration-tests/suites/new-module-registry/index.ts b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/index.ts
new file mode 100644
index 000000000000..21cd5c7e529e
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/index.ts
@@ -0,0 +1,36 @@
+import * as Sentry from '@sentry/cloudflare';
+import { DurableObject } from 'cloudflare:workers';
+
+interface Env {
+ SENTRY_DSN: string;
+ TEST_DURABLE_OBJECT: DurableObjectNamespace;
+}
+
+export class TestDurableObject extends DurableObject {
+ async sayHello(name: string): Promise {
+ return `Hello, ${name}`;
+ }
+}
+
+export default {
+ async fetch(request: Request, env: Env): Promise {
+ const { pathname } = new URL(request.url);
+
+ // `import.meta.resolve` only exists with the new module registry.
+ if (pathname === '/import-meta-resolve') {
+ return new Response(typeof import.meta.resolve);
+ }
+
+ if (pathname === '/error') {
+ throw new Error('Error with the new module registry');
+ }
+
+ if (pathname === '/durable-object') {
+ const stub = env.TEST_DURABLE_OBJECT.get(env.TEST_DURABLE_OBJECT.idFromName('test'));
+ return new Response(await stub.sayHello('world'));
+ }
+
+ Sentry.startSpan({ name: 'test-span', op: 'test' }, () => {});
+ return new Response('OK');
+ },
+} satisfies ExportedHandler;
diff --git a/dev-packages/cloudflare-integration-tests/suites/new-module-registry/instrument.server.ts b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/instrument.server.ts
new file mode 100644
index 000000000000..e577550ae0b8
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/instrument.server.ts
@@ -0,0 +1,6 @@
+import { defineCloudflareOptions } from '@sentry/cloudflare';
+
+export default defineCloudflareOptions((env: { SENTRY_DSN: string }) => ({
+ dsn: env.SENTRY_DSN,
+ tracesSampleRate: 1.0,
+}));
diff --git a/dev-packages/cloudflare-integration-tests/suites/new-module-registry/test.ts b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/test.ts
new file mode 100644
index 000000000000..295e7d7aac10
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/test.ts
@@ -0,0 +1,60 @@
+import type { Event } from '@sentry/core';
+import { HTTP_SERVER, RPC } from '@sentry/conventions/op';
+import { expect, it } from 'vitest';
+import { createRunner } from '../../runner';
+import { getSpanOp, getSpansFromEnvelope } from '../../spanUtils';
+
+it('runs the worker with the new module registry', async ({ signal }) => {
+ const runner = createRunner(__dirname).start(signal);
+ expect(await runner.makeRequest('get', '/import-meta-resolve')).toBe('function');
+});
+
+it('captures errors thrown by the fetch handler', async ({ signal }) => {
+ const runner = createRunner(__dirname)
+ .expect(envelope => {
+ const event = envelope[1]?.[0]?.[1] as Event;
+ expect(event.exception?.values?.[0]).toEqual({
+ type: 'Error',
+ value: 'Error with the new module registry',
+ stacktrace: { frames: expect.any(Array) },
+ mechanism: { type: 'auto.http.cloudflare', handled: false },
+ });
+ })
+ .unordered()
+ .start(signal);
+
+ await runner.makeRequest('get', '/error', { expectError: true });
+ await runner.completed();
+});
+
+it('sends the spans of the fetch handler', async ({ signal }) => {
+ const runner = createRunner(__dirname).start(signal);
+ const spansPromise = runner.collectStreamedSpans(spansOfTrace => spansOfTrace.length === 2);
+
+ await runner.makeRequest('get', '/');
+
+ const spans = await spansPromise;
+ const segmentSpan = spans.find(span => span.is_segment);
+ const childSpan = spans.find(span => span.name === 'test-span');
+
+ expect(segmentSpan?.name).toBe('GET /');
+ expect(getSpanOp(segmentSpan!)).toBe(HTTP_SERVER);
+ expect(childSpan?.parent_span_id).toBe(segmentSpan?.span_id);
+ expect(getSpanOp(childSpan!)).toBe('test');
+});
+
+it('traces Durable Object RPC calls', async ({ signal }) => {
+ const runner = createRunner(__dirname)
+ .expect(envelope => {
+ const segmentSpan = getSpansFromEnvelope(envelope).find(span => span.is_segment);
+ expect(segmentSpan?.name).toBe('sayHello');
+ expect(getSpanOp(segmentSpan!)).toBe(RPC);
+ })
+ .unordered()
+ .start(signal);
+
+ const response = await runner.makeRequest('get', '/durable-object');
+ expect(response).toBe('Hello, world');
+
+ await runner.completed();
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/new-module-registry/vite.config.mts b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/vite.config.mts
new file mode 100644
index 000000000000..005f4448f6cb
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/vite.config.mts
@@ -0,0 +1,7 @@
+import { cloudflare } from '@cloudflare/vite-plugin';
+import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ plugins: [cloudflare(), sentryCloudflareVitePlugin()],
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/new-module-registry/wrangler.jsonc b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/wrangler.jsonc
new file mode 100644
index 000000000000..85ceb154ea5c
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/new-module-registry/wrangler.jsonc
@@ -0,0 +1,12 @@
+{
+ "$schema": "../../node_modules/wrangler/config-schema.json",
+ "name": "new-module-registry",
+ "main": "index.ts",
+ "compatibility_date": "2025-06-17",
+ // `new_module_registry` becomes the default for compatibility dates from 2026-11-17 on.
+ "compatibility_flags": ["nodejs_compat", "new_module_registry"],
+ "durable_objects": {
+ "bindings": [{ "name": "TEST_DURABLE_OBJECT", "class_name": "TestDurableObject" }],
+ },
+ "migrations": [{ "tag": "v1", "new_sqlite_classes": ["TestDurableObject"] }],
+}
diff --git a/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts b/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts
index adf52419022f..430e5baf0487 100644
--- a/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts
+++ b/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts
@@ -224,12 +224,12 @@ it('sends a streamed span envelope with correct spans for a manually started spa
value: '/',
},
'url.port': {
- type: 'string',
- value: expect.stringMatching(/^\d{4,5}$/),
+ type: 'integer',
+ value: expect.any(Number),
},
'url.scheme': {
type: 'string',
- value: 'http:',
+ value: 'http',
},
'user_agent.original': {
type: 'string',
diff --git a/dev-packages/cloudflare-integration-tests/suites/tail-stream/index-producer.ts b/dev-packages/cloudflare-integration-tests/suites/tail-stream/index-producer.ts
new file mode 100644
index 000000000000..4bc14ed89a89
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tail-stream/index-producer.ts
@@ -0,0 +1,5 @@
+export default {
+ async fetch() {
+ return new Response('ok');
+ },
+} satisfies ExportedHandler;
diff --git a/dev-packages/cloudflare-integration-tests/suites/tail-stream/index.ts b/dev-packages/cloudflare-integration-tests/suites/tail-stream/index.ts
new file mode 100644
index 000000000000..70632becce3a
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tail-stream/index.ts
@@ -0,0 +1,19 @@
+interface Env {
+ PRODUCER: Fetcher;
+}
+
+// Nothing is wrapped manually, the Vite plugin wraps the default export.
+export default {
+ async fetch(_request, env) {
+ return env.PRODUCER.fetch('http://fake-host/');
+ },
+ // workerd calls `tailStream()` with the producer's onset event, then calls
+ // the returned object for the later events of that invocation.
+ tailStream() {
+ return {
+ outcome() {
+ throw new Error('Error from the tailStream outcome handler');
+ },
+ };
+ },
+} satisfies ExportedHandler;
diff --git a/dev-packages/cloudflare-integration-tests/suites/tail-stream/instrument.server.ts b/dev-packages/cloudflare-integration-tests/suites/tail-stream/instrument.server.ts
new file mode 100644
index 000000000000..9de8aec879bb
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tail-stream/instrument.server.ts
@@ -0,0 +1,5 @@
+import { defineCloudflareOptions } from '@sentry/cloudflare';
+
+export default defineCloudflareOptions((env: { SENTRY_DSN: string }) => ({
+ dsn: env.SENTRY_DSN,
+}));
diff --git a/dev-packages/cloudflare-integration-tests/suites/tail-stream/test.ts b/dev-packages/cloudflare-integration-tests/suites/tail-stream/test.ts
new file mode 100644
index 000000000000..3d906ace27bb
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tail-stream/test.ts
@@ -0,0 +1,25 @@
+import type { Event } from '@sentry/core';
+import { join } from 'path';
+import { expect, it } from 'vitest';
+import { createRunner } from '../../runner';
+
+it('captures errors thrown by the handler that tailStream returns', async ({ signal }) => {
+ const runner = createRunner(__dirname)
+ // A tail consumer in another `wrangler dev` process does not receive
+ // streaming tail events, so the producer runs in the same process.
+ .withWranglerArgs('-c', join(__dirname, 'dist/cloudflare_tail_stream_producer/wrangler.json'))
+ .expect(envelope => {
+ const event = envelope[1][0]?.[1] as Event;
+ expect(event.exception?.values?.[0]).toEqual(
+ expect.objectContaining({
+ type: 'Error',
+ value: 'Error from the tailStream outcome handler',
+ mechanism: { type: 'auto.faas.cloudflare.tail_stream', handled: false },
+ }),
+ );
+ })
+ .start(signal);
+
+ await runner.makeRequest('get', '/');
+ await runner.completed();
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/tail-stream/vite.config.mts b/dev-packages/cloudflare-integration-tests/suites/tail-stream/vite.config.mts
new file mode 100644
index 000000000000..71ebb6c3e6fa
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tail-stream/vite.config.mts
@@ -0,0 +1,10 @@
+import { cloudflare } from '@cloudflare/vite-plugin';
+import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ plugins: [
+ cloudflare({ auxiliaryWorkers: [{ configPath: './wrangler-producer.jsonc' }] }),
+ sentryCloudflareVitePlugin(),
+ ],
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/tail-stream/wrangler-producer.jsonc b/dev-packages/cloudflare-integration-tests/suites/tail-stream/wrangler-producer.jsonc
new file mode 100644
index 000000000000..97e22bd98f7d
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tail-stream/wrangler-producer.jsonc
@@ -0,0 +1,8 @@
+{
+ "$schema": "../../node_modules/wrangler/config-schema.json",
+ "name": "cloudflare-tail-stream-producer",
+ "main": "index-producer.ts",
+ "compatibility_date": "2025-06-17",
+ "compatibility_flags": ["nodejs_compat"],
+ "streaming_tail_consumers": [{ "service": "cloudflare-tail-stream-consumer" }],
+}
diff --git a/dev-packages/cloudflare-integration-tests/suites/tail-stream/wrangler.jsonc b/dev-packages/cloudflare-integration-tests/suites/tail-stream/wrangler.jsonc
new file mode 100644
index 000000000000..0f4b2e593c3c
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tail-stream/wrangler.jsonc
@@ -0,0 +1,8 @@
+{
+ "$schema": "../../node_modules/wrangler/config-schema.json",
+ "name": "cloudflare-tail-stream-consumer",
+ "main": "index.ts",
+ "compatibility_date": "2025-06-17",
+ "compatibility_flags": ["nodejs_compat"],
+ "services": [{ "binding": "PRODUCER", "service": "cloudflare-tail-stream-producer" }],
+}
diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/index.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/index.ts
new file mode 100644
index 000000000000..4da39ebf2b88
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/index.ts
@@ -0,0 +1,18 @@
+import * as Sentry from '@sentry/cloudflare';
+
+// `getActiveSpan` and `Span.spanContext` are newer than the installed workers types, and older runtimes do not have
+// them.
+interface CloudflareTracing {
+ getActiveSpan?(): { isTraced?: boolean; spanContext?(): { traceId: string; spanId: string } } | undefined;
+}
+
+export default {
+ async fetch(_request, _env, ctx) {
+ const span = (ctx.tracing as unknown as CloudflareTracing | undefined)?.getActiveSpan?.();
+ const spanContext = span?.isTraced ? span.spanContext?.() : undefined;
+
+ Sentry.captureException(new Error('Error in a Cloudflare trace'));
+
+ return Response.json(spanContext ? { traceId: spanContext.traceId, spanId: spanContext.spanId } : null);
+ },
+} satisfies ExportedHandler;
diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/instrument.server.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/instrument.server.ts
new file mode 100644
index 000000000000..0d33b7bb23d0
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/instrument.server.ts
@@ -0,0 +1,6 @@
+import { defineCloudflareOptions } from '@sentry/cloudflare';
+
+export default defineCloudflareOptions((env: { SENTRY_DSN: string; TRACES_SAMPLE_RATE: string }) => ({
+ dsn: env.SENTRY_DSN,
+ tracesSampleRate: env.TRACES_SAMPLE_RATE ? Number(env.TRACES_SAMPLE_RATE) : undefined,
+}));
diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/test.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/test.ts
new file mode 100644
index 000000000000..2f6323969634
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/test.ts
@@ -0,0 +1,104 @@
+import type { Event, SerializedStreamedSpanContainer } from '@sentry/core';
+import { expect, it } from 'vitest';
+import { SHORT_UUID_MATCHER, UUID_MATCHER } from '../../../expect';
+import { createRunner } from '../../../runner';
+import { supports } from '../../../runtime';
+
+// `Span.spanContext()` ships in workerd 1.20261009.1. Without it, the Worker responds with `null`.
+it.runIf(supports({ minWorkerd: '1.20261009.1' }))(
+ 'uses the Cloudflare trace for the error event when tracing is not set up',
+ async ({ signal }) => {
+ const errorEvents: Event[] = [];
+
+ const runner = createRunner(__dirname)
+ .expect(envelope => {
+ expect(envelope[1][0][0].type).toBe('event');
+ errorEvents.push(envelope[1][0][1] as Event);
+ })
+ .start(signal);
+
+ const cloudflareSpan = await runner.makeRequest<{ traceId: string; spanId: string } | null>('get', '/');
+ await runner.completed();
+
+ expect(cloudflareSpan).toEqual({ traceId: UUID_MATCHER, spanId: SHORT_UUID_MATCHER });
+ expect(errorEvents).toHaveLength(1);
+ expect(errorEvents[0]?.contexts?.trace).toEqual({
+ trace_id: cloudflareSpan?.traceId,
+ span_id: SHORT_UUID_MATCHER,
+ parent_span_id: cloudflareSpan?.spanId,
+ });
+ },
+);
+
+it.runIf(supports({ minWorkerd: '1.20261009.1' }))(
+ 'starts its own trace when tracing is set up',
+ async ({ signal }) => {
+ const errorEvents: Event[] = [];
+ const spanContainers: SerializedStreamedSpanContainer[] = [];
+
+ const runner = createRunner(__dirname)
+ .withWranglerArgs('--var', 'TRACES_SAMPLE_RATE:1')
+ .unordered()
+ .expect(envelope => {
+ expect(envelope[1][0][0].type).toBe('event');
+ errorEvents.push(envelope[1][0][1] as Event);
+ })
+ .expect(envelope => {
+ expect(envelope[1][0][0].type).toBe('span');
+ spanContainers.push(envelope[1][0][1] as SerializedStreamedSpanContainer);
+ })
+ .start(signal);
+
+ const cloudflareSpan = await runner.makeRequest<{ traceId: string; spanId: string } | null>('get', '/');
+ await runner.completed();
+
+ const segmentSpans = spanContainers.flatMap(container => container.items).filter(span => span.is_segment);
+ expect(cloudflareSpan).toEqual({ traceId: UUID_MATCHER, spanId: SHORT_UUID_MATCHER });
+ expect(errorEvents).toHaveLength(1);
+ expect(segmentSpans).toHaveLength(1);
+ expect(segmentSpans[0]?.trace_id).not.toBe(cloudflareSpan?.traceId);
+ expect(segmentSpans[0]?.parent_span_id).toBeUndefined();
+ expect(errorEvents[0]?.contexts?.trace?.trace_id).toBe(segmentSpans[0]?.trace_id);
+ },
+);
+
+it.skipIf(supports({ minWorkerd: '1.20261009.1' }))(
+ 'starts its own trace on runtimes without `Span.spanContext()`',
+ async ({ signal }) => {
+ const errorEvents: Event[] = [];
+
+ const runner = createRunner(__dirname)
+ .expect(envelope => {
+ expect(envelope[1][0][0].type).toBe('event');
+ errorEvents.push(envelope[1][0][1] as Event);
+ })
+ .start(signal);
+
+ const cloudflareSpan = await runner.makeRequest<{ traceId: string; spanId: string } | null>('get', '/');
+ await runner.completed();
+
+ expect(cloudflareSpan).toBeNull();
+ expect(errorEvents).toHaveLength(1);
+ expect(errorEvents[0]?.contexts?.trace).toEqual({ trace_id: UUID_MATCHER, span_id: SHORT_UUID_MATCHER });
+ },
+);
+
+it('continues an incoming Sentry trace instead of the Cloudflare trace', async ({ signal }) => {
+ const errorEvents: Event[] = [];
+
+ const runner = createRunner(__dirname)
+ .expect(envelope => {
+ expect(envelope[1][0][0].type).toBe('event');
+ errorEvents.push(envelope[1][0][1] as Event);
+ })
+ .start(signal);
+
+ await runner.makeRequest('get', '/', {
+ headers: { 'sentry-trace': '12345678901234567890123456789012-1234567890123456-1' },
+ });
+ await runner.completed();
+
+ expect(errorEvents).toHaveLength(1);
+ expect(errorEvents[0]?.contexts?.trace?.trace_id).toBe('12345678901234567890123456789012');
+ expect(errorEvents[0]?.contexts?.trace?.parent_span_id).toBe('1234567890123456');
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/vite.config.mts b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/vite.config.mts
new file mode 100644
index 000000000000..005f4448f6cb
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/vite.config.mts
@@ -0,0 +1,7 @@
+import { cloudflare } from '@cloudflare/vite-plugin';
+import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ plugins: [cloudflare(), sentryCloudflareVitePlugin()],
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/wrangler.jsonc b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/wrangler.jsonc
new file mode 100644
index 000000000000..37b1010b07a7
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/tracing/cloudflare-trace/wrangler.jsonc
@@ -0,0 +1,9 @@
+{
+ "name": "cloudflare-trace-worker",
+ "compatibility_date": "2025-06-17",
+ "main": "index.ts",
+ "compatibility_flags": ["nodejs_compat"],
+ "vars": {
+ "TRACES_SAMPLE_RATE": "",
+ },
+}
diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/dsc-url-source/test.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/dsc-url-source/test.ts
index f9916e5c03c7..fb98b6ed2bc5 100644
--- a/dev-packages/cloudflare-integration-tests/suites/tracing/dsc-url-source/test.ts
+++ b/dev-packages/cloudflare-integration-tests/suites/tracing/dsc-url-source/test.ts
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest';
-import { eventEnvelope } from '../../../expect';
+import { eventEnvelope, SHORT_UUID_MATCHER, UUID_MATCHER } from '../../../expect';
import { createRunner } from '../../../runner';
import { getSpanOp, getSpansFromEnvelope } from '../../../spanUtils';
@@ -29,6 +29,12 @@ it('omits the span name from the DSC for url-source spans when tracing is enable
method: 'GET',
url: expect.any(String),
},
+ contexts: {
+ trace: {
+ trace_id: UUID_MATCHER,
+ span_id: SHORT_UUID_MATCHER,
+ },
+ },
},
{ includeSamplingFields: true, includeSampleRand: true, includeTransaction: false },
),
diff --git a/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/index.ts b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/index.ts
new file mode 100644
index 000000000000..4f77c798e2e2
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/index.ts
@@ -0,0 +1,105 @@
+import * as Sentry from '@sentry/cloudflare';
+import { WorkflowEntrypoint } from 'cloudflare:workers';
+import type { WorkflowEvent, WorkflowStep } from 'cloudflare:workers';
+import { NonRetryableError } from 'cloudflare:workflows';
+
+interface Env {
+ SENTRY_DSN: string;
+ RUN_ERRORS_WORKFLOW: Workflow;
+}
+
+interface WorkflowParams {
+ mode: string;
+}
+
+export class RunErrorsTestWorkflow extends WorkflowEntrypoint {
+ async run(event: WorkflowEvent, step: WorkflowStep): Promise {
+ const { mode } = event.payload;
+
+ if (mode === 'throw-before-step') {
+ throw new TypeError('Thrown before any step');
+ }
+
+ if (mode === 'non-retryable-before-step') {
+ throw new NonRetryableError('Non-retryable before any step');
+ }
+
+ if (mode === 'throw-after-step') {
+ await step.do('successful-step', async () => 'done');
+ throw new Error('Thrown after a successful step');
+ }
+
+ if (mode === 'wait-for-event-timeout') {
+ await step.waitForEvent('wait-for-event', { type: 'never-sent', timeout: '1 second' });
+ }
+
+ if (mode === 'step-timeout') {
+ await step.do('slow-step', { timeout: '1 second', retries: { limit: 0, delay: 100 } }, async () => {
+ await new Promise(resolve => setTimeout(resolve, 5000));
+ });
+ }
+
+ if (mode === 'non-serializable') {
+ await step.do(
+ 'non-serializable-step',
+ { retries: { limit: 0, delay: 100 } },
+ (async () => () => 'function') as () => Promise,
+ );
+ }
+
+ if (mode === 'throw-in-step') {
+ await step.do('failing-step', { retries: { limit: 0, delay: 100 } }, async () => {
+ throw new Error('Thrown inside the step callback');
+ });
+ }
+
+ if (mode === 'caught-step-error') {
+ try {
+ await step.do('failing-step', { retries: { limit: 0, delay: 100 } }, async () => {
+ throw new Error('Thrown inside the step callback');
+ });
+ } catch {
+ // The workflow goes on after the failed step
+ }
+ }
+
+ if (mode === 'rethrow-new-error') {
+ try {
+ await step.do('failing-step', { retries: { limit: 0, delay: 100 } }, async () => {
+ throw new Error('Thrown inside the step callback');
+ });
+ } catch {
+ throw new Error('Thrown by run() after the failed step');
+ }
+ }
+ }
+}
+
+export default {
+ async fetch(request, env, _ctx) {
+ const url = new URL(request.url);
+
+ if (url.pathname === '/trigger-workflow') {
+ const instance = await env.RUN_ERRORS_WORKFLOW.create({
+ params: { mode: url.searchParams.get('mode') || '' },
+ });
+
+ return Response.json({ id: instance.id });
+ }
+
+ if (url.pathname === '/flush-marker') {
+ Sentry.captureMessage('flush-marker');
+ return Response.json({ ok: true });
+ }
+
+ const statusMatch = url.pathname.match(/^\/workflow-status\/(.+)$/);
+
+ if (statusMatch) {
+ const instance = await env.RUN_ERRORS_WORKFLOW.get(statusMatch[1]!);
+
+ return Response.json({ id: statusMatch[1], status: await instance.status() });
+ }
+
+ return new Response('Not found', { status: 404 });
+ },
+} satisfies ExportedHandler;
diff --git a/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/instrument.server.ts b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/instrument.server.ts
new file mode 100644
index 000000000000..9de8aec879bb
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/instrument.server.ts
@@ -0,0 +1,5 @@
+import { defineCloudflareOptions } from '@sentry/cloudflare';
+
+export default defineCloudflareOptions((env: { SENTRY_DSN: string }) => ({
+ dsn: env.SENTRY_DSN,
+}));
diff --git a/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/test.ts b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/test.ts
new file mode 100644
index 000000000000..6913c1f133b2
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/test.ts
@@ -0,0 +1,161 @@
+import type { Envelope } from '@sentry/core';
+import { expect, it } from 'vitest';
+import { createRunner } from '../../../runner';
+
+interface TriggerResponse {
+ id: string;
+}
+
+interface StatusResponse {
+ id: string;
+ status: { status: string };
+}
+
+interface SentException {
+ type?: string;
+ value?: string;
+ mechanism?: { handled?: boolean; type?: string };
+}
+
+async function waitForWorkflowStatus(
+ makeRequest: (method: 'get' | 'post', path: string) => Promise,
+ workflowId: string,
+): Promise {
+ for (let i = 0; i < 30; i++) {
+ const status = await makeRequest('get', `/workflow-status/${workflowId}`);
+ if (status?.status?.status === 'errored' || status?.status?.status === 'complete') {
+ return status;
+ }
+ await new Promise(r => setTimeout(r, 200));
+ }
+ return undefined;
+}
+
+// The flush marker is sent after the instance has ended and must arrive directly after the expected
+// error event. A second error event for the same failure would arrive in its place and fail the test.
+const flushMarkerMatcher = (envelope: Envelope): void => {
+ const [, items] = envelope;
+ const [itemHeader, itemBody] = items[0] as [{ type: string }, Record];
+
+ expect(itemHeader.type).toBe('event');
+ expect(itemBody.message).toBe('flush-marker');
+};
+
+it.for([
+ { mode: 'throw-before-step', type: 'TypeError', value: 'Thrown before any step' },
+ { mode: 'non-retryable-before-step', type: 'NonRetryableError', value: 'Non-retryable before any step' },
+ { mode: 'throw-after-step', type: 'Error', value: 'Thrown after a successful step' },
+ { mode: 'wait-for-event-timeout', type: 'Error', value: expect.stringContaining('timed out') },
+ { mode: 'step-timeout', type: 'Error', value: expect.stringContaining('timed out') },
+ { mode: 'non-serializable', type: 'Error', value: expect.stringContaining('not serialisable') },
+])(
+ 'captures one unhandled error when run() fails outside a step callback ($mode)',
+ async ({ mode, type, value }, { signal }) => {
+ const runner = createRunner(__dirname)
+ .expect((envelope: Envelope): void => {
+ const [, items] = envelope;
+ const [itemHeader, itemBody] = items[0] as [{ type: string }, { exception?: { values?: SentException[] } }];
+
+ expect(itemHeader.type).toBe('event');
+ expect(itemBody.exception?.values?.[0]).toMatchObject({
+ type,
+ value,
+ mechanism: { handled: false, type: 'auto.faas.cloudflare.workflow' },
+ });
+ })
+ .expect(flushMarkerMatcher)
+ .start(signal);
+
+ const trigger = await runner.makeRequest('get', `/trigger-workflow?mode=${mode}`);
+ expect(trigger?.id).toBeDefined();
+
+ const status = await waitForWorkflowStatus(runner.makeRequest.bind(runner), trigger!.id);
+ expect(status?.status?.status).toBe('errored');
+
+ await runner.makeRequest('get', '/flush-marker');
+ await runner.completed();
+ },
+);
+
+it('captures an error thrown inside a step callback only one time', async ({ signal }) => {
+ const runner = createRunner(__dirname)
+ .expect((envelope: Envelope): void => {
+ const [, items] = envelope;
+ const [itemHeader, itemBody] = items[0] as [{ type: string }, { exception?: { values?: SentException[] } }];
+
+ expect(itemHeader.type).toBe('event');
+ expect(itemBody.exception?.values?.[0]).toMatchObject({
+ type: 'Error',
+ value: 'Thrown inside the step callback',
+ mechanism: { handled: true, type: 'auto.faas.cloudflare.workflow' },
+ });
+ })
+ .expect(flushMarkerMatcher)
+ .start(signal);
+
+ const trigger = await runner.makeRequest('get', '/trigger-workflow?mode=throw-in-step');
+ expect(trigger?.id).toBeDefined();
+
+ const status = await waitForWorkflowStatus(runner.makeRequest.bind(runner), trigger!.id);
+ expect(status?.status?.status).toBe('errored');
+
+ await runner.makeRequest('get', '/flush-marker');
+ await runner.completed();
+});
+
+it('captures no second error when run() catches a failed step', async ({ signal }) => {
+ const runner = createRunner(__dirname)
+ .expect((envelope: Envelope): void => {
+ const [, items] = envelope;
+ const [itemHeader, itemBody] = items[0] as [{ type: string }, { exception?: { values?: SentException[] } }];
+
+ expect(itemHeader.type).toBe('event');
+ expect(itemBody.exception?.values?.[0]?.value).toBe('Thrown inside the step callback');
+ })
+ .expect(flushMarkerMatcher)
+ .start(signal);
+
+ const trigger = await runner.makeRequest('get', '/trigger-workflow?mode=caught-step-error');
+ expect(trigger?.id).toBeDefined();
+
+ const status = await waitForWorkflowStatus(runner.makeRequest.bind(runner), trigger!.id);
+ expect(status?.status?.status).toBe('complete');
+
+ await runner.makeRequest('get', '/flush-marker');
+ await runner.completed();
+});
+
+it('captures the step error and the new error when run() replaces a failed step error', async ({ signal }) => {
+ const runner = createRunner(__dirname)
+ .expect((envelope: Envelope): void => {
+ const [, items] = envelope;
+ const [itemHeader, itemBody] = items[0] as [{ type: string }, { exception?: { values?: SentException[] } }];
+
+ expect(itemHeader.type).toBe('event');
+ expect(itemBody.exception?.values?.[0]).toMatchObject({
+ value: 'Thrown inside the step callback',
+ mechanism: { handled: true, type: 'auto.faas.cloudflare.workflow' },
+ });
+ })
+ .expect((envelope: Envelope): void => {
+ const [, items] = envelope;
+ const [itemHeader, itemBody] = items[0] as [{ type: string }, { exception?: { values?: SentException[] } }];
+
+ expect(itemHeader.type).toBe('event');
+ expect(itemBody.exception?.values?.[0]).toMatchObject({
+ value: 'Thrown by run() after the failed step',
+ mechanism: { handled: false, type: 'auto.faas.cloudflare.workflow' },
+ });
+ })
+ .expect(flushMarkerMatcher)
+ .start(signal);
+
+ const trigger = await runner.makeRequest('get', '/trigger-workflow?mode=rethrow-new-error');
+ expect(trigger?.id).toBeDefined();
+
+ const status = await waitForWorkflowStatus(runner.makeRequest.bind(runner), trigger!.id);
+ expect(status?.status?.status).toBe('errored');
+
+ await runner.makeRequest('get', '/flush-marker');
+ await runner.completed();
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/vite.config.mts b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/vite.config.mts
new file mode 100644
index 000000000000..005f4448f6cb
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/vite.config.mts
@@ -0,0 +1,7 @@
+import { cloudflare } from '@cloudflare/vite-plugin';
+import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ plugins: [cloudflare(), sentryCloudflareVitePlugin()],
+});
diff --git a/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/wrangler.jsonc b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/wrangler.jsonc
new file mode 100644
index 000000000000..c70373ceb803
--- /dev/null
+++ b/dev-packages/cloudflare-integration-tests/suites/workflows/run-errors/wrangler.jsonc
@@ -0,0 +1,13 @@
+{
+ "name": "workflow-run-errors-test",
+ "compatibility_date": "2026-05-01",
+ "main": "index.ts",
+ "compatibility_flags": ["nodejs_compat"],
+ "workflows": [
+ {
+ "name": "run-errors-test-workflow",
+ "binding": "RUN_ERRORS_WORKFLOW",
+ "class_name": "RunErrorsTestWorkflow",
+ },
+ ],
+}
diff --git a/dev-packages/deno-integration-tests/package.json b/dev-packages/deno-integration-tests/package.json
index f91826f278bc..36221d8d7d38 100644
--- a/dev-packages/deno-integration-tests/package.json
+++ b/dev-packages/deno-integration-tests/package.json
@@ -17,7 +17,7 @@
},
"devDependencies": {
"@sentry-internal/node-integration-tests": "11.12.0",
- "@sentry/conventions": "^0.32.0",
+ "@sentry/conventions": "^0.33.0",
"@sentry/core": "11.12.0",
"@sentry/deno": "11.12.0",
"mysql": "^2.18.1",
diff --git a/dev-packages/e2e-tests/.env.example b/dev-packages/e2e-tests/.env.example
index 17326f227680..4417292a006c 100644
--- a/dev-packages/e2e-tests/.env.example
+++ b/dev-packages/e2e-tests/.env.example
@@ -23,5 +23,7 @@ E2E_OPENAI_DECISIONS_API_KEY=
# Cloudflare credentials for E2E tests that deploy a real Worker (e.g. cloudflare-workers-send-to-sentry).
# The API token needs "Workers Scripts: Edit" on the account; "Workers KV Storage: Read" additionally silences a
# warning when a worker is deleted. Leave it empty to use a `wrangler login` session instead.
+# Apps that read Workers Logs (e.g. cloudflare-workers-without-tracing-send-to-sentry) need an API token with
+# "Workers Observability: Edit".
CLOUDFLARE_API_TOKEN=
CLOUDFLARE_ACCOUNT_ID=
diff --git a/dev-packages/e2e-tests/README.md b/dev-packages/e2e-tests/README.md
index be2b94586ece..49f3db499220 100644
--- a/dev-packages/e2e-tests/README.md
+++ b/dev-packages/e2e-tests/README.md
@@ -152,6 +152,9 @@ Apps like `cloudflare-workers-send-to-sentry` deploy the built app as a real Wor
`cloudflare-flue-send-to-sentry/src/auth.ts`.
- Add the `workerPrefix` to `.github/workflows/cleanup-e2e-workers.yml`, which deletes the Worker of a PR when the PR
closes.
+- To check what Cloudflare stored for a request (for example its Cloudflare trace id), read Workers Logs with
+ `fetchWorkersLogsEvents`. `CLOUDFLARE_API_TOKEN` then also needs "Workers Observability: Edit". See
+ `cloudflare-workers-without-tracing-send-to-sentry`.
- Set `"sentryTest": { "optional": true }` in `package.json`, because only the optional CI job has the Cloudflare
secrets.
@@ -173,9 +176,9 @@ is the reference setup.
(`instrument.mjs`), Bun `@sentry/bun` (`instrument.bun.mjs`), Deno `@sentry/deno` (`instrument.deno.mjs`) and
Cloudflare `@sentry/cloudflare`. The framework SDK only provides the framework wrappers on the other runtimes, so
values that come from its `init()` (`sdk.name`, default integrations) are Node-only. Next.js is different: it loads
- `instrumentation.ts` on every runtime, so `nextjs-16` calls `init()` of `@sentry/nextjs` on Bun and Deno too, and
- adds the integrations of `@sentry/bun` or `@sentry/deno` that replace the Node instrumentation those runtimes do not
- trigger.
+ `instrumentation.ts` on every runtime, so `nextjs-16` calls `init()` of `@sentry/nextjs` on Bun and Deno too. Its
+ Bun and Deno variants build the app on that runtime, so `@sentry/nextjs` loads its `bun` or `deno` entry, which adds
+ the integrations of `@sentry/bun` or `@sentry/deno`.
- **Start commands**: `playwright.config.mjs` selects the start command with `getRuntime()`. Bun and Deno use the same build
as Node and only change the start command, for example
`bun --bun --preload ./instrument.bun.mjs ./node_modules/@react-router/serve/bin.cjs ./build/server/index.js` and
@@ -207,10 +210,13 @@ is the reference setup.
replaces `vite.config.ts`. For a variant with `runtime`, the runner copies these files over the others in the
temporary copy of the app, before the build. This needs no framework or bundler config. A build in the app folder
itself does not get these files, so run a variant with `pnpm run test:run --variant `.
-- **Deno version**: a variant can pin the Deno version, for example `"deno-version": "v2.9.0"`.
+- **Bun and Deno versions**: a variant can pin the Bun or Deno version, for example `"bun-version": "1.4.4"` or
+ `"deno-version": "v2.9.0"`.
- **Bun**: under `bun run` the SDK cannot inject diagnostics channels into packages that stay outside the build (for
example Express behind `react-router-serve`), so those produce no spans on Bun. Where a test depends on them, branch
- on `RUNTIME` and say why in a comment.
+ on `RUNTIME` and say why in a comment. An app that starts its own server can instead bundle it with
+ `@sentry/bun/plugin`, as `nestjs-12/bun-build.mjs` does. Bun 1.3 renames classes in bundles (`class Foo2`), which
+ changes span names taken from class names, so `nestjs-12` pins Bun 1.4 (see #26289).
```json
"sentryTest": {
@@ -296,6 +302,10 @@ of a test application.
set its `assert-command` to run production tests and add a development variant to run both environments in parallel.
The local `test:assert` script can still run both; select the base variant locally with `--variant
}>
+
+
+ );
+}
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/package.json b/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/package.json
index 4292a42c3843..0f36bae7bf66 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/package.json
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/package.json
@@ -35,7 +35,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
index f06c4da961cd..35ef14d5e14d 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
@@ -5,11 +5,23 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
const APP = 'nextjs-16-cacheComponents';
+const PAGE_SERVER_RENDERING_AGE = 'page.server_rendering.age';
+
+async function getRenderStart(page: Page): Promise {
+ return Number(await page.locator('meta[name="sentry-render-start"]').getAttribute('content'));
+}
+
+function expectedRenderAge(pageloadStart: number, renderStart: number): number {
+ return Math.max(0, Math.floor(pageloadStart - renderStart));
+}
+
+// A self-hosted server sends the trace of the request in a `Server-Timing` header of a document
+// that renders for the request, which reaches the browser before any HTML, so the pageload continues
+// it right away. A document that a shared cache may store gets no header, as a CDN would replay it.
// The server only writes `sentry-trace` meta tags for a render that happened for the current request,
-// never while it prerenders a shell. So a tag in the document can always be continued; the only
-// question is when it arrives. The resumed part of a prerendered shell arrives after the SDK started,
-// which the pageload instrumentation waits for. A shell prerendered at runtime carries a
-// `sentry-cache-origin` tag instead, which marks the pageload as static and links the prerender.
+// never while it prerenders a shell. A shell prerendered at runtime carries a `sentry-cache-origin`
+// tag instead, which links the prerender and, together with a late `sentry-trace` tag, marks the
+// pageload as partially static.
test('connects the pageload trace to the runtime server request', async ({ page }) => {
// The shell is prerendered, but the page's dynamic part (`DynamicContent` awaits `headers()`)
@@ -24,7 +36,7 @@ test('connects the pageload trace to the runtime server request', async ({ page
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/pageload-tracing';
});
- await page.goto('/pageload-tracing');
+ const response = await page.goto('/pageload-tracing');
await expect(page.locator('#todos-fetched')).toHaveText('Todos fetched: 5');
@@ -32,6 +44,16 @@ test('connects the pageload trace to the runtime server request', async ({ page
expect(serverTx.contexts?.trace?.trace_id).toBeTruthy();
expect(pageloadTx.contexts?.trace?.trace_id).toBe(serverTx.contexts?.trace?.trace_id);
+ // The header carries the trace before any HTML, so the pageload does not wait for the meta tag. Both
+ // are computed inside the request, so the pageload hangs off one of the request's spans. In dev mode
+ // nothing is prerendered, so the tag is in from the start and wins over the header.
+ const serverSpanIds = [serverTx.contexts?.trace?.span_id, ...(serverTx.spans ?? []).map(span => span.span_id)];
+ const [, headerSpanId] =
+ new RegExp(`sentry-trace;desc="${serverTx.contexts?.trace?.trace_id}-([a-f0-9]{16})-1"`).exec(
+ response?.headers()['server-timing'] ?? '',
+ ) ?? [];
+ expect(serverSpanIds).toContain(headerSpanId);
+ expect(serverSpanIds).toContain(pageloadTx.contexts?.trace?.parent_span_id);
});
test('connects the pageload trace to a blocking render', async ({ page }) => {
@@ -60,10 +82,17 @@ test('does not share a trace between visitors of a shell generated at request ti
// `[id]` only lists `test` in `generateStaticParams`, so the first visit prerenders and caches the
// shell for this id. The prerender writes no trace tag, only a `sentry-cache-origin` tag with its own
- // trace, so every visitor starts a fresh trace that links the prerender and is marked as static.
+ // trace, so every visitor starts a fresh trace that links the prerender and is marked as static. The
+ // cached document is cacheable by a CDN as well, so the response carries no trace header either.
const id = `shell-${Date.now()}`;
- const visit = async (): Promise<{ traceId: string | undefined; links: unknown; serverRenderingType: unknown }> => {
+ const visit = async (): Promise<{
+ traceId: string | undefined;
+ links: unknown;
+ serverRenderingType: unknown;
+ renderAge: unknown;
+ expectedRenderAge: number;
+ }> => {
const context = await browser.newContext();
const page: Page = await context.newPage();
@@ -74,10 +103,13 @@ test('does not share a trace between visitors of a shell generated at request ti
);
});
- await page.goto(`/${id}`);
+ const response = await page.goto(`/${id}`);
await expect(page.locator('#result')).toHaveText(`Hello, ${id}!`);
expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
expect(await page.locator('meta[name="sentry-cache-origin"]').count()).toBe(1);
+ expect(await page.locator('meta[name="sentry-render-start"]').count()).toBe(1);
+ const renderStart = await getRenderStart(page);
+ expect(response?.headers()['server-timing'] ?? '').not.toContain('sentry-trace');
const pageloadTx = await pageloadTxPromise;
await context.close();
@@ -86,6 +118,8 @@ test('does not share a trace between visitors of a shell generated at request ti
traceId: pageloadTx.contexts?.trace?.trace_id,
links: pageloadTx.contexts?.trace?.links,
serverRenderingType: pageloadTx.contexts?.trace?.data?.['page.server_rendering.type'],
+ renderAge: pageloadTx.contexts?.trace?.data?.[PAGE_SERVER_RENDERING_AGE],
+ expectedRenderAge: expectedRenderAge(pageloadTx.start_timestamp!, renderStart),
};
};
@@ -97,6 +131,8 @@ test('does not share a trace between visitors of a shell generated at request ti
expect(second.traceId).not.toBe(first.traceId);
expect(first.serverRenderingType).toBe('static');
expect(second.serverRenderingType).toBe('static');
+ expect(first.renderAge).toBe(first.expectedRenderAge);
+ expect(second.renderAge).toBe(second.expectedRenderAge);
// Both link the request that prerendered the shell, which is the first visitor's own request. The
// client cannot tell the first visit from later ones, so that pageload starts a fresh trace too.
@@ -146,6 +182,7 @@ test('continues the request trace on a shell prerendered at runtime and links th
const [prerenderTraceId, prerenderSpanId] = (await page
.locator('meta[name="sentry-cache-origin"]')
.getAttribute('content'))!.split('-');
+ const renderStart = await getRenderStart(page);
const pageloadTx = await pageloadTxPromise;
@@ -153,6 +190,9 @@ test('continues the request trace on a shell prerendered at runtime and links th
// pageload continues that trace.
expect(pageloadTx.contexts?.trace?.trace_id).toBe(requestTraceId);
expect(pageloadTx.contexts?.trace?.data?.['page.server_rendering.type']).toBe('partially_static');
+ expect(pageloadTx.contexts?.trace?.data?.[PAGE_SERVER_RENDERING_AGE]).toBe(
+ expectedRenderAge(pageloadTx.start_timestamp!, renderStart),
+ );
expect(pageloadTx.contexts?.trace?.links).toEqual([
{
trace_id: prerenderTraceId,
@@ -171,22 +211,29 @@ test('starts a fresh trace on a fully static page', async ({ page }) => {
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/static-shell';
});
- await page.goto('/static-shell');
+ const response = await page.goto('/static-shell');
await expect(page.locator('#static-shell')).toHaveText('Static shell');
const pageloadTx = await pageloadTxPromise;
// A build-time shell carries no trace context and no marker, the SDK does not run during the build.
+ // The response is cacheable, so the request that serves it sends no trace header either.
expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
expect(await page.locator('meta[name="sentry-cache-origin"]').count()).toBe(0);
+ expect(await page.locator('meta[name="sentry-render-start"]').count()).toBe(0);
+ expect(response?.headers()['server-timing'] ?? '').not.toContain('sentry-trace');
expect(pageloadTx.contexts?.trace?.trace_id).toBeTruthy();
expect(pageloadTx.contexts?.trace?.links).toBeUndefined();
expect(pageloadTx.contexts?.trace?.data?.['page.server_rendering.type']).toBeUndefined();
+ expect(pageloadTx.contexts?.trace?.data?.[PAGE_SERVER_RENDERING_AGE]).toBeUndefined();
});
-test('keeps a navigation that starts while the pageload waits for the trace meta tag', async ({ page }) => {
- test.skip(process.env.TEST_ENV !== 'production', 'Only a prerendered shell makes the trace meta tag arrive late');
+test('keeps a navigation that starts while the document still streams', async ({ page }) => {
+ test.skip(
+ process.env.TEST_ENV !== 'production',
+ 'Only a prerendered shell streams the rest of the document after the SDK started',
+ );
const pageloadTxPromise = waitForTransaction(APP, transactionEvent => {
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/slow-hole';
@@ -199,7 +246,7 @@ test('keeps a navigation that starts while the pageload waits for the trace meta
await page.goto('/slow-hole', { waitUntil: 'commit' });
await page.waitForFunction(() => !!(window as { next?: { router?: unknown } }).next?.router);
- // The resumed part, which carries the tag, has not arrived yet, so the pageload is still waiting.
+ // The resumed part, which carries the tag, has not arrived yet. The header already connected the pageload.
await expect(page.locator('#slow-fallback')).toBeVisible();
expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
@@ -212,3 +259,22 @@ test('keeps a navigation that starts while the pageload waits for the trace meta
expect(pageloadTx.contexts?.trace?.data?.['sentry.idle_span_finish_reason']).toBe('cancelled');
expect(navigationTx.contexts?.trace?.data?.['sentry.idle_span_finish_reason']).toBe('idleTimeout');
});
+
+test('continues the header trace without a link when the trace meta tag arrives late', async ({ page }) => {
+ test.skip(process.env.TEST_ENV !== 'production', 'Only a prerendered shell makes the trace meta tag arrive late');
+ test.setTimeout(60_000);
+
+ const pageloadTxPromise = waitForTransaction(APP, transactionEvent => {
+ return transactionEvent.transaction === '/slow-stream' && transactionEvent.contexts?.trace?.op === 'pageload';
+ });
+
+ await page.goto('/slow-stream', { waitUntil: 'commit' });
+ await expect(page.locator('#slow-content')).toBeVisible({ timeout: 20_000 });
+ const [requestTraceId] = (await page.locator('meta[name="sentry-trace"]').getAttribute('content'))!.split('-');
+
+ const pageloadTx = await pageloadTxPromise;
+
+ // The header connected the pageload before the tag arrived, so the late tag adds no link.
+ expect(pageloadTx.contexts?.trace?.trace_id).toBe(requestTraceId);
+ expect(pageloadTx.contexts?.trace?.links).toBeUndefined();
+});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-standalone/tests/build-output.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-standalone/tests/build-output.test.ts
index 936ff77b6494..fa21afb7e171 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-standalone/tests/build-output.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-standalone/tests/build-output.test.ts
@@ -1,5 +1,6 @@
import { expect, test } from '@playwright/test';
import { findAbsolutePathImports } from '@sentry-internal/test-utils';
+import { spawnSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
@@ -14,19 +15,29 @@ test('emits no absolute-path imports into the relocated standalone output', () =
expect(leaks).toEqual([]);
});
-// Regression test for the bug this app surfaced (JS-3451): `register.ts` reaches the ESM loader
-// hook through `Module.register(...)`, a runtime call `@vercel/nft` cannot trace. The hook was
-// therefore never copied into the standalone output, and channel-based instrumentation failed to
-// register, silently, behind `debug: true`. Asserting on the traced output rather than on emitted
-// telemetry, because Next.js records its server spans through its own wrapping either way, so the
-// tests in `standalone.test.ts` stay green even when channel injection is dead.
-test('traces the orchestrion ESM loader hook into the standalone output', () => {
- const standaloneDir = path.join(process.cwd(), '.next', 'standalone');
- const hookSuffix = path.join('@sentry', 'server-runtime-injection', 'build', 'esm', 'hook.js');
+// Regression test for JS-3451 and JS-4067. `register.ts` hands the loader hook to
+// `Module.register()` by runtime path, so the standalone output must ship the hook and everything it
+// loads: first `@vercel/nft` didn't trace the hook at all, then Turbopack shipped it without its
+// imports. Either way channel injection failed to register, silently, behind `debug: true`. This
+// checks the registration marker rather than emitted telemetry, because Next.js records its server
+// spans through its own wrapping either way. The runner's Node takes the `Module.registerHooks` path,
+// which never loads the hook, so force the `Module.register()` path that Node < 24.13 takes.
+test('registers the orchestrion loader hook from the standalone output', () => {
+ const registerSuffix = path.join('@sentry', 'server-runtime-injection', 'build', 'cjs', 'register.js');
+ const registerPath = fs
+ .readdirSync(path.join(process.cwd(), '.next', 'standalone'), { recursive: true, withFileTypes: true })
+ .map(entry => path.join(entry.parentPath, entry.name))
+ .find(file => file.endsWith(registerSuffix));
+ expect(registerPath).toBeDefined();
- const found = fs
- .readdirSync(standaloneDir, { recursive: true, withFileTypes: true })
- .some(entry => entry.isFile() && path.join(entry.parentPath, entry.name).endsWith(hookSuffix));
+ const script = `
+ require('node:module').registerHooks = undefined;
+ require(${JSON.stringify(registerPath)}).registerDiagnosticsChannelInjection();
+ const marker = globalThis.__SENTRY__?.__SENTRY_ORCHESTRION__ ?? globalThis.__SENTRY_ORCHESTRION__;
+ process.stdout.write(JSON.stringify(marker));
+ `;
+ const { stdout, stderr } = spawnSync(process.execPath, ['-e', script], { encoding: 'utf8' });
- expect(found).toBe(true);
+ expect(stderr).not.toContain('Failed to register diagnostics-channel injection hooks');
+ expect(JSON.parse(stdout)).toEqual({ runtime: [] });
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/app/slow-stream/page.tsx b/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/app/slow-stream/page.tsx
new file mode 100644
index 000000000000..478ac04626a6
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/app/slow-stream/page.tsx
@@ -0,0 +1,20 @@
+import { headers } from 'next/headers';
+import { Suspense } from 'react';
+
+// Above the pageload's 10 second wait for the trace meta tag, but short enough that the tag still
+// arrives before the pageload ends.
+const DELAY_MS = 10_500;
+
+async function SlowContent() {
+ await headers();
+ await new Promise(resolve => setTimeout(resolve, DELAY_MS));
+ return
Slow content
;
+}
+
+export default function Page() {
+ return (
+ Loading...}>
+
+
+ );
+}
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/package.json b/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/package.json
index 6da961d2bf6c..3b6a13f4c579 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/package.json
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/package.json
@@ -32,7 +32,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
index 3d1512789f82..84c5b9fa5495 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/tests/cacheOrigin-pageloadConnection.spec.ts
@@ -5,11 +5,23 @@ import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
const APP = 'nextjs-16-streaming-cacheComponents';
+const PAGE_SERVER_RENDERING_AGE = 'page.server_rendering.age';
+
+async function getRenderStart(page: Page): Promise {
+ return Number(await page.locator('meta[name="sentry-render-start"]').getAttribute('content'));
+}
+
+function expectedRenderAge(pageloadStart: number, renderStart: number): number {
+ return Math.max(0, Math.floor(pageloadStart - renderStart));
+}
+
+// A self-hosted server sends the trace of the request in a `Server-Timing` header of a document
+// that renders for the request, which reaches the browser before any HTML, so the pageload continues
+// it right away. A document that a shared cache may store gets no header, as a CDN would replay it.
// The server only writes `sentry-trace` meta tags for a render that happened for the current request,
-// never while it prerenders a shell. So a tag in the document can always be continued; the only
-// question is when it arrives. The resumed part of a prerendered shell arrives after the SDK started,
-// which the pageload instrumentation waits for. A shell prerendered at runtime carries a
-// `sentry-cache-origin` tag instead, which marks the pageload as static and links the prerender.
+// never while it prerenders a shell. A shell prerendered at runtime carries a `sentry-cache-origin`
+// tag instead, which links the prerender and, together with a late `sentry-trace` tag, marks the
+// pageload as partially static.
test('connects the pageload trace to the runtime server request', async ({ page }) => {
// The shell is prerendered, but the page's dynamic part (`DynamicContent` awaits `headers()`)
@@ -22,7 +34,7 @@ test('connects the pageload trace to the runtime server request', async ({ page
return span.name === '/pageload-tracing' && getSpanOp(span) === 'pageload' && span.is_segment;
});
- await page.goto('/pageload-tracing');
+ const response = await page.goto('/pageload-tracing');
await expect(page.locator('#todos-fetched')).toHaveText('Todos fetched: 5');
@@ -30,6 +42,8 @@ test('connects the pageload trace to the runtime server request', async ({ page
expect(serverSpan.trace_id).toBeTruthy();
expect(pageloadSpan.trace_id).toBe(serverSpan.trace_id);
+ // The header carries the trace before any HTML, so the pageload does not wait for the meta tag.
+ expect(response?.headers()['server-timing']).toContain(`sentry-trace;desc="${serverSpan.trace_id}-`);
});
test('connects the pageload trace to a blocking render', async ({ page }) => {
@@ -58,10 +72,17 @@ test('does not share a trace between visitors of a shell generated at request ti
// `[id]` only lists `test` in `generateStaticParams`, so the first visit prerenders and caches the
// shell for this id. The prerender writes no trace tag, only a `sentry-cache-origin` tag with its own
- // trace, so every visitor starts a fresh trace that links the prerender and is marked as static.
+ // trace, so every visitor starts a fresh trace that links the prerender and is marked as static. The
+ // cached document is cacheable by a CDN as well, so the response carries no trace header either.
const id = `shell-${Date.now()}`;
- const visit = async (): Promise<{ traceId: string | undefined; links: unknown; serverRenderingType: unknown }> => {
+ const visit = async (): Promise<{
+ traceId: string | undefined;
+ links: unknown;
+ serverRenderingType: unknown;
+ renderAge: unknown;
+ expectedRenderAge: number;
+ }> => {
const context = await browser.newContext();
const page: Page = await context.newPage();
@@ -69,10 +90,13 @@ test('does not share a trace between visitors of a shell generated at request ti
return getSpanOp(span) === 'pageload' && span.is_segment && span.attributes['url.path']?.value === `/${id}`;
});
- await page.goto(`/${id}`);
+ const response = await page.goto(`/${id}`);
await expect(page.locator('#result')).toHaveText(`Hello, ${id}!`);
expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
expect(await page.locator('meta[name="sentry-cache-origin"]').count()).toBe(1);
+ expect(await page.locator('meta[name="sentry-render-start"]').count()).toBe(1);
+ const renderStart = await getRenderStart(page);
+ expect(response?.headers()['server-timing'] ?? '').not.toContain('sentry-trace');
const pageloadSpan = await pageloadSpanPromise;
await context.close();
@@ -81,6 +105,8 @@ test('does not share a trace between visitors of a shell generated at request ti
traceId: pageloadSpan.trace_id,
links: pageloadSpan.links,
serverRenderingType: pageloadSpan.attributes['page.server_rendering.type']?.value,
+ renderAge: pageloadSpan.attributes[PAGE_SERVER_RENDERING_AGE]?.value,
+ expectedRenderAge: expectedRenderAge(pageloadSpan.start_timestamp, renderStart),
};
};
@@ -92,6 +118,8 @@ test('does not share a trace between visitors of a shell generated at request ti
expect(second.traceId).not.toBe(first.traceId);
expect(first.serverRenderingType).toBe('static');
expect(second.serverRenderingType).toBe('static');
+ expect(first.renderAge).toBe(first.expectedRenderAge);
+ expect(second.renderAge).toBe(second.expectedRenderAge);
// Both link the request that prerendered the shell, which is the first visitor's own request. The
// client cannot tell the first visit from later ones, so that pageload starts a fresh trace too.
@@ -142,6 +170,7 @@ test('continues the request trace on a shell prerendered at runtime and links th
const [prerenderTraceId, prerenderSpanId] = (await page
.locator('meta[name="sentry-cache-origin"]')
.getAttribute('content'))!.split('-');
+ const renderStart = await getRenderStart(page);
const pageloadSpan = await pageloadSpanPromise;
@@ -149,6 +178,9 @@ test('continues the request trace on a shell prerendered at runtime and links th
// pageload continues that trace.
expect(pageloadSpan.trace_id).toBe(requestTraceId);
expect(pageloadSpan.attributes['page.server_rendering.type']?.value).toBe('partially_static');
+ expect(pageloadSpan.attributes[PAGE_SERVER_RENDERING_AGE]?.value).toBe(
+ expectedRenderAge(pageloadSpan.start_timestamp, renderStart),
+ );
expect(pageloadSpan.links).toEqual([
{
trace_id: prerenderTraceId,
@@ -167,22 +199,29 @@ test('starts a fresh trace on a fully static page', async ({ page }) => {
return span.name === '/static-shell' && getSpanOp(span) === 'pageload' && span.is_segment;
});
- await page.goto('/static-shell');
+ const response = await page.goto('/static-shell');
await expect(page.locator('#static-shell')).toHaveText('Static shell');
const pageloadSpan = await pageloadSpanPromise;
// A build-time shell carries no trace context and no marker, the SDK does not run during the build.
+ // The response is cacheable, so the request that serves it sends no trace header either.
expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
expect(await page.locator('meta[name="sentry-cache-origin"]').count()).toBe(0);
+ expect(await page.locator('meta[name="sentry-render-start"]').count()).toBe(0);
+ expect(response?.headers()['server-timing'] ?? '').not.toContain('sentry-trace');
expect(pageloadSpan.trace_id).toBeTruthy();
expect(pageloadSpan.links).toBeUndefined();
expect(pageloadSpan.attributes['page.server_rendering.type']).toBeUndefined();
+ expect(pageloadSpan.attributes[PAGE_SERVER_RENDERING_AGE]).toBeUndefined();
});
-test('keeps a navigation that starts while the pageload waits for the trace meta tag', async ({ page }) => {
- test.skip(process.env.TEST_ENV !== 'production', 'Only a prerendered shell makes the trace meta tag arrive late');
+test('keeps a navigation that starts while the document still streams', async ({ page }) => {
+ test.skip(
+ process.env.TEST_ENV !== 'production',
+ 'Only a prerendered shell streams the rest of the document after the SDK started',
+ );
const pageloadSpanPromise = waitForStreamedSpan(APP, span => {
return span.name === '/slow-hole' && getSpanOp(span) === 'pageload' && span.is_segment;
@@ -195,7 +234,7 @@ test('keeps a navigation that starts while the pageload waits for the trace meta
await page.goto('/slow-hole', { waitUntil: 'commit' });
await page.waitForFunction(() => !!(window as { next?: { router?: unknown } }).next?.router);
- // The resumed part, which carries the tag, has not arrived yet, so the pageload is still waiting.
+ // The resumed part, which carries the tag, has not arrived yet. The header already connected the pageload.
await expect(page.locator('#slow-fallback')).toBeVisible();
expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
@@ -211,3 +250,22 @@ test('keeps a navigation that starts while the pageload waits for the trace meta
value: 'idleTimeout',
});
});
+
+test('continues the header trace without a link when the trace meta tag arrives late', async ({ page }) => {
+ test.skip(process.env.TEST_ENV !== 'production', 'Only a prerendered shell makes the trace meta tag arrive late');
+ test.setTimeout(60_000);
+
+ const pageloadSpanPromise = waitForStreamedSpan(APP, span => {
+ return span.name === '/slow-stream' && getSpanOp(span) === 'pageload' && span.is_segment;
+ });
+
+ await page.goto('/slow-stream', { waitUntil: 'commit' });
+ await expect(page.locator('#slow-content')).toBeVisible({ timeout: 20_000 });
+ const [requestTraceId] = (await page.locator('meta[name="sentry-trace"]').getAttribute('content'))!.split('-');
+
+ const pageloadSpan = await pageloadSpanPromise;
+
+ // The header connected the pageload before the tag arrived, so the late tag adds no link.
+ expect(pageloadSpan.trace_id).toBe(requestTraceId);
+ expect(pageloadSpan.links).toBeUndefined();
+});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/instrumentation-client.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/instrumentation-client.ts
index 84b61b956e4a..3762bb3d7d8c 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/instrumentation-client.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/instrumentation-client.ts
@@ -4,7 +4,8 @@ import { SENTRY_DSN } from './sentry-dsn';
Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: SENTRY_DSN,
- // No tunnel option - using tunnelRoute from withSentryConfig
+ // The other variants use the tunnelRoute of withSentryConfig
+ tunnel: process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE === 'managed' ? true : undefined,
tracesSampleRate: 1.0,
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/next.config.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/next.config.ts
index ac79f882a572..d060076a192c 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/next.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/next.config.ts
@@ -1,9 +1,13 @@
import { withSentryConfig } from '@sentry/nextjs/config';
import type { NextConfig } from 'next';
-const nextConfig: NextConfig = {};
+// The managed variants serve the managed tunnel under a base path and with trailing slashes, without a tunnel route.
+const tunnelMode = process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE;
+const isManagedMode = tunnelMode === 'managed';
+
+const nextConfig: NextConfig = isManagedMode ? { basePath: '/docs', trailingSlash: true } : {};
export default withSentryConfig(nextConfig, {
silent: true,
- tunnelRoute: true,
+ tunnelRoute: isManagedMode ? undefined : tunnelMode === 'path' ? '/monitoring' : true,
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/package.json b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/package.json
index ca42dc5e99a1..afc5bd63ab7d 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/package.json
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/package.json
@@ -4,26 +4,25 @@
"private": true,
"scripts": {
"dev": " next dev",
- "build": "_SENTRY_TUNNEL_DESTINATION_OVERRIDE=http://localhost:3031/ next build > .tmp_build_stdout 2> .tmp_build_stderr || (cat .tmp_build_stdout && cat .tmp_build_stderr && exit 1)",
+ "build": "next build > .tmp_build_stdout 2> .tmp_build_stderr || (cat .tmp_build_stdout && cat .tmp_build_stderr && exit 1)",
"clean": "npx rimraf node_modules pnpm-lock.yaml .tmp_dev_server_logs",
- "dev:webpack": "_SENTRY_TUNNEL_DESTINATION_OVERRIDE=http://localhost:3031/ next dev --webpack",
- "build-webpack": "_SENTRY_TUNNEL_DESTINATION_OVERRIDE=http://localhost:3031/ next build --webpack > .tmp_build_stdout 2> .tmp_build_stderr || (cat .tmp_build_stdout && cat .tmp_build_stderr && exit 1)",
- "start": "_SENTRY_TUNNEL_DESTINATION_OVERRIDE=http://localhost:3031/ next start",
+ "dev:webpack": "next dev --webpack",
+ "build-webpack": "next build --webpack > .tmp_build_stdout 2> .tmp_build_stderr || (cat .tmp_build_stdout && cat .tmp_build_stderr && exit 1)",
+ "start": "next start",
"lint": "eslint",
"test:prod": "TEST_ENV=production playwright test",
- "test:dev": "TEST_ENV=development _SENTRY_TUNNEL_DESTINATION_OVERRIDE=http://localhost:3031/ playwright test",
- "test:dev-webpack": "TEST_ENV=development-webpack _SENTRY_TUNNEL_DESTINATION_OVERRIDE=http://localhost:3031/ playwright test",
+ "test:dev": "TEST_ENV=development playwright test",
+ "test:dev-webpack": "TEST_ENV=development-webpack playwright test",
"test:build": "pnpm install && pnpm build",
"test:build-webpack": "pnpm install && pnpm build-webpack",
- "test:build-handler": "pnpm install && cp -R tunnel-handler/node/sentry-tunnel app/ && pnpm build",
- "test:build-handler-webpack": "pnpm install && cp -R tunnel-handler/edge/sentry-tunnel app/ && pnpm build-webpack",
+ "test:build-middleware-webpack": "pnpm install && rm proxy.ts && cp tunnel-middleware/middleware.ts middleware.ts && pnpm build-webpack",
"test:build-canary": "pnpm install && pnpm add next@canary && pnpm build",
"test:build-latest": "pnpm install && pnpm add next@latest && pnpm build",
"test:build-latest-webpack": "pnpm install && pnpm add next@latest && pnpm build-webpack",
"test:build-canary-webpack": "pnpm install && pnpm add next@canary && pnpm build-webpack",
"test:assert": "pnpm test:prod && pnpm test:dev",
"test:assert-webpack": "pnpm test:prod && pnpm test:dev-webpack",
- "test:build:cloudflare": "pnpm install && _SENTRY_TUNNEL_DESTINATION_OVERRIDE=http://localhost:3031/ opennextjs-cloudflare build",
+ "test:build:cloudflare": "pnpm install && opennextjs-cloudflare build",
"start:cloudflare": "opennextjs-cloudflare preview"
},
"dependencies": {
@@ -37,7 +36,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
@@ -50,23 +49,28 @@
"variants": [
{
"build-command": "pnpm test:build-webpack",
- "label": "nextjs-16-tunnel (webpack)",
+ "label": "nextjs-16-tunnel (tunnelRoute: true, webpack)",
"assert-command": "pnpm test:assert-webpack"
},
{
"build-command": "pnpm test:build",
- "label": "nextjs-16-tunnel (turbopack)",
+ "label": "nextjs-16-tunnel (tunnelRoute: true, turbopack)",
"assert-command": "pnpm test:assert"
},
{
- "build-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=handler pnpm test:build-handler",
- "label": "nextjs-16-tunnel (handler, turbopack)",
- "assert-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=handler pnpm test:assert"
+ "build-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=path pnpm test:build",
+ "label": "nextjs-16-tunnel (tunnelRoute path, turbopack)",
+ "assert-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=path pnpm test:assert"
},
{
- "build-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=handler pnpm test:build-handler-webpack",
- "label": "nextjs-16-tunnel (handler, webpack, edge)",
- "assert-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=handler pnpm test:assert-webpack"
+ "build-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=managed pnpm test:build",
+ "label": "nextjs-16-tunnel (managed, turbopack)",
+ "assert-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=managed pnpm test:assert"
+ },
+ {
+ "build-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=managed pnpm test:build-middleware-webpack",
+ "label": "nextjs-16-tunnel (managed, webpack, edge middleware)",
+ "assert-command": "NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE=managed pnpm test:assert-webpack"
}
],
"optionalVariants": [
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry-dsn.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry-dsn.ts
index fa0ad467f9bc..1030f61fd5cb 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry-dsn.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry-dsn.ts
@@ -1,6 +1,3 @@
-// The handler variants send the server events to the event proxy too, so the tests also see server spans.
-export const SENTRY_DSN =
- process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE === 'handler'
- ? 'http://public@localhost:3031/1337'
- : // A fake but properly formatted Sentry SaaS DSN, because the rewrite mode tunnels only SaaS DSNs
- 'https://public@o12345.ingest.us.sentry.io/67890';
+// The server forwards the tunnel requests to the host of the DSN, so the event proxy gets the browser events and the
+// server spans.
+export const SENTRY_DSN = 'http://public@localhost:3031/1337';
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.edge.config.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.edge.config.ts
index 0333aa29412b..4a999c80e920 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.edge.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.edge.config.ts
@@ -4,7 +4,8 @@ import { SENTRY_DSN } from './sentry-dsn';
Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: SENTRY_DSN,
- // No tunnel option - using tunnelRoute from withSentryConfig
+ // Serves the managed tunnel of the managed variants
+ integrations: process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE === 'managed' ? [Sentry.serveTunnelIntegration()] : [],
tracesSampleRate: 1.0,
// debug: true,
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.server.config.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.server.config.ts
index 0333aa29412b..4a999c80e920 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.server.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.server.config.ts
@@ -4,7 +4,8 @@ import { SENTRY_DSN } from './sentry-dsn';
Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: SENTRY_DSN,
- // No tunnel option - using tunnelRoute from withSentryConfig
+ // Serves the managed tunnel of the managed variants
+ integrations: process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE === 'managed' ? [Sentry.serveTunnelIntegration()] : [],
tracesSampleRate: 1.0,
// debug: true,
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tests/tunnel-managed.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tests/tunnel-managed.test.ts
new file mode 100644
index 000000000000..fc4d05998566
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tests/tunnel-managed.test.ts
@@ -0,0 +1,109 @@
+import { expect, test } from '@playwright/test';
+import { HTTP_REQUEST_METHOD, URL_FULL } from '@sentry/conventions/attributes';
+import { getSpanOp, waitForRequest, waitForStreamedSpan, waitForStreamedSpans } from '@sentry-internal/test-utils';
+import type { Event, SerializedStreamedSpan } from '@sentry/core';
+
+test.skip(process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE !== 'managed', 'Only the managed variants use it');
+
+const BASE_PATH = '/docs';
+
+function getStringAttribute(span: SerializedStreamedSpan, key: string): string | undefined {
+ const attribute = span.attributes[key];
+ return attribute?.type === 'string' ? attribute.value : undefined;
+}
+
+// With `trailingSlash`, a POST to the path without the slash would get a redirect.
+function isTunnelPath(pathname: string): boolean {
+ return /^\/docs\/[a-z0-9]+\/$/.test(pathname);
+}
+
+test('sends the pageload span through the managed tunnel under the base path', async ({ page, baseURL }) => {
+ const pageloadSpanPromise = waitForStreamedSpan('nextjs-16-tunnel', span => {
+ return getSpanOp(span) === 'pageload' && span.is_segment;
+ });
+ const tunnelResponsePromise = page.waitForResponse(
+ response =>
+ response.request().method() === 'POST' &&
+ new URL(response.url()).origin === baseURL &&
+ (response.request().postData() ?? '').includes('pageload'),
+ );
+
+ await page.goto(BASE_PATH);
+
+ const tunnelResponse = await tunnelResponsePromise;
+ const pageloadSpan = await pageloadSpanPromise;
+
+ expect(isTunnelPath(new URL(tunnelResponse.url()).pathname)).toBe(true);
+ expect(tunnelResponse.status()).toBe(200);
+ expect(pageloadSpan.status).toBe('ok');
+});
+
+test('forwards events without the cookies of the browser', async ({ page, context, baseURL }) => {
+ await context.addCookies([{ name: 'session', value: '8f2c1d', url: baseURL }]);
+ const proxyRequestPromise = waitForRequest('nextjs-16-tunnel', ({ envelope }) =>
+ envelope[1].some(
+ ([itemHeader, item]) =>
+ itemHeader.type === 'event' && (item as Event).exception?.values?.[0]?.value === 'Tunnel managed cookie test',
+ ),
+ );
+
+ await page.goto(BASE_PATH);
+ await page.waitForFunction(() => typeof (window as { __SENTRY__?: unknown }).__SENTRY__ === 'object');
+ const tunnelRequestPromise = page.waitForRequest(
+ request =>
+ request.method() === 'POST' &&
+ new URL(request.url()).origin === baseURL &&
+ (request.postData() ?? '').includes('Tunnel managed cookie test'),
+ );
+ await page.evaluate(() => {
+ setTimeout(() => {
+ throw new Error('Tunnel managed cookie test');
+ });
+ });
+
+ const tunnelRequest = await tunnelRequestPromise;
+ const proxyRequest = await proxyRequestPromise;
+
+ expect(isTunnelPath(new URL(tunnelRequest.url()).pathname)).toBe(true);
+ expect((await tunnelRequest.allHeaders()).cookie).toBe('session=8f2c1d');
+ expect(proxyRequest.rawProxyRequestHeaders.cookie).toBeUndefined();
+ expect(proxyRequest.rawProxyRequestHeaders['content-type']).toBe('application/x-sentry-envelope');
+});
+
+test('does not create server spans for tunnel requests', async ({ page, baseURL }) => {
+ // One listener, so it gets every span that the proxy received before the barrier span.
+ const spansBeforeBarrier: SerializedStreamedSpan[] = [];
+ const barrierSpanPromise = waitForStreamedSpans('nextjs-16-tunnel', spans => {
+ spansBeforeBarrier.push(...spans);
+ return spans.some(span => span.is_segment && span.name === 'GET /api/flush');
+ });
+ const pageloadTunnelResponsePromise = page.waitForResponse(
+ response =>
+ response.request().method() === 'POST' &&
+ new URL(response.url()).origin === baseURL &&
+ (response.request().postData() ?? '').includes('pageload'),
+ );
+
+ await page.goto(BASE_PATH);
+ await pageloadTunnelResponsePromise;
+ // The first flush sends the tunnel spans, the second one the barrier span of the first flush.
+ await page.request.get(`${BASE_PATH}/api/flush`);
+ await page.request.get(`${BASE_PATH}/api/flush`);
+ await barrierSpanPromise;
+
+ // The middleware span of the page request arrived, so the ones of the tunnel requests would have too.
+ expect(spansBeforeBarrier.some(span => span.name === 'middleware GET')).toBe(true);
+
+ const postSpans = spansBeforeBarrier.filter(
+ span =>
+ span.name.includes('POST') ||
+ getStringAttribute(span, HTTP_REQUEST_METHOD) === 'POST' ||
+ getStringAttribute(span, 'http.method') === 'POST',
+ );
+ const ingestSpans = spansBeforeBarrier.filter(
+ span =>
+ getSpanOp(span) === 'http.client' && !!getStringAttribute(span, URL_FULL)?.startsWith('http://localhost:3031/'),
+ );
+ expect(postSpans).toEqual([]);
+ expect(ingestSpans).toEqual([]);
+});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tests/tunnel-route.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tests/tunnel-route.test.ts
index e0c1b5e273ae..f75d167f9deb 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tests/tunnel-route.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tests/tunnel-route.test.ts
@@ -1,134 +1,70 @@
import { expect, test } from '@playwright/test';
-import { HTTP_REQUEST_METHOD, SERVER_ADDRESS, URL_FULL } from '@sentry/conventions/attributes';
+import { HTTP_REQUEST_METHOD, URL_FULL } from '@sentry/conventions/attributes';
import { getSpanOp, waitForRequest, waitForStreamedSpan, waitForStreamedSpans } from '@sentry-internal/test-utils';
import type { Event, SerializedStreamedSpan } from '@sentry/core';
+test.skip(
+ process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE === 'managed',
+ 'The managed variants have no tunnel route, see tunnel-managed.test.ts',
+);
+
function getStringAttribute(span: SerializedStreamedSpan, key: string): string | undefined {
const attribute = span.attributes[key];
return attribute?.type === 'string' ? attribute.value : undefined;
}
-test('Tunnel route should proxy pageload span to Sentry', async ({ page }) => {
- // Wait for the pageload span to be sent through the tunnel
+// `tunnelRoute: '/monitoring'` in the `path` variant, `tunnelRoute: true` (the path derived from the DSN) otherwise.
+function isTunnelPath(pathname: string): boolean {
+ return process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE === 'path'
+ ? pathname === '/monitoring'
+ : /^\/[a-z0-9]{1,7}$/.test(pathname);
+}
+
+test('sends the pageload span through the tunnel route', async ({ page, baseURL }) => {
const pageloadSpanPromise = waitForStreamedSpan('nextjs-16-tunnel', span => {
return getSpanOp(span) === 'pageload' && span.name === '/' && span.is_segment;
});
+ const tunnelResponsePromise = page.waitForResponse(
+ response =>
+ response.request().method() === 'POST' &&
+ new URL(response.url()).origin === baseURL &&
+ (response.request().postData() ?? '').includes('pageload'),
+ );
- // Navigate to the page
await page.goto('/');
+ const tunnelResponse = await tunnelResponsePromise;
const pageloadSpan = await pageloadSpanPromise;
- // Verify the pageload span was received successfully
- expect(pageloadSpan).toBeDefined();
- expect(pageloadSpan.name).toBe('/');
- expect(getSpanOp(pageloadSpan)).toBe('pageload');
+ expect(isTunnelPath(new URL(tunnelResponse.url()).pathname)).toBe(true);
+ expect(tunnelResponse.status()).toBe(200);
expect(pageloadSpan.status).toBe('ok');
});
-test('Tunnel route should send multiple pageload spans consistently', async ({ page }) => {
- // This test verifies that the tunnel route remains consistent across multiple page loads
- // (important for Turbopack which could generate different tunnel routes for client/server)
-
- // First pageload
+test('sends the pageload spans of every page load through the tunnel route', async ({ page }) => {
const firstPageloadPromise = waitForStreamedSpan('nextjs-16-tunnel', span => {
return getSpanOp(span) === 'pageload' && span.name === '/' && span.is_segment;
});
await page.goto('/');
- const firstPageload = await firstPageloadPromise;
- expect(firstPageload).toBeDefined();
- expect(firstPageload.name).toBe('/');
- expect(getSpanOp(firstPageload)).toBe('pageload');
- expect(firstPageload.status).toBe('ok');
+ expect((await firstPageloadPromise).status).toBe('ok');
- // Second pageload (reload)
const secondPageloadPromise = waitForStreamedSpan('nextjs-16-tunnel', span => {
return getSpanOp(span) === 'pageload' && span.name === '/' && span.is_segment;
});
await page.reload();
- const secondPageload = await secondPageloadPromise;
- expect(secondPageload).toBeDefined();
- expect(secondPageload.name).toBe('/');
- expect(getSpanOp(secondPageload)).toBe('pageload');
- expect(secondPageload.status).toBe('ok');
+ expect((await secondPageloadPromise).status).toBe('ok');
});
-test('Tunnel requests should not create middleware or fetch spans', async ({ page }) => {
- // This test verifies that our span filtering logic works correctly
- // The proxy runs on all routes, so we'll get a middleware span for `/`
- // But we should NOT get middleware or fetch spans for the tunnel route itself
-
- // Accumulate every streamed span for the duration of the test. The callback never returns true,
- // so this promise is deliberately left unsettled - the assertions below read the array instead.
- const allSpans: SerializedStreamedSpan[] = [];
- void waitForStreamedSpans('nextjs-16-tunnel', spans => {
- allSpans.push(...spans);
- return false;
- });
-
- // Wait for pageload span
- const pageloadPromise = waitForStreamedSpan('nextjs-16-tunnel', span => {
- return getSpanOp(span) === 'pageload' && span.is_segment;
- });
-
- await page.goto('/');
- const pageloadSpan = await pageloadPromise;
-
- // Trigger errors to force tunnel POST requests
- await page
- .evaluate(() => {
- throw new Error('Test tunnel error 1');
- })
- .catch(() => {
- // Expected to throw
- });
-
- await page
- .evaluate(() => {
- throw new Error('Test tunnel error 2');
- })
- .catch(() => {
- // Expected to throw
- });
-
- // Wait for events to be sent through tunnel, and for the spans they would wrongly produce to arrive
- await page.waitForTimeout(3000);
-
- // We should have received the pageload span
- expect(pageloadSpan).toBeDefined();
- expect(getSpanOp(pageloadSpan)).toBe('pageload');
-
- const middlewareSpans = allSpans.filter(span => getSpanOp(span) === 'middleware');
-
- // We WILL have a middleware span for GET / (the pageload)
- // But we should NOT have middleware spans for POST requests (tunnel route)
- const postMiddlewareSpans = middlewareSpans.filter(
- span => span.name.includes('POST') || getStringAttribute(span, HTTP_REQUEST_METHOD) === 'POST',
- );
-
- expect(postMiddlewareSpans).toHaveLength(0);
-
- // We should NOT have any fetch spans to Sentry ingest. Matched on the host attribute rather than a
- // substring of the full URL, which would also match an arbitrary host with `sentry.io` elsewhere in it.
- const sentryFetchSpans = allSpans.filter(span => {
- const host = getStringAttribute(span, SERVER_ADDRESS) ?? '';
- return getSpanOp(span) === 'http.client' && (host === 'sentry.io' || host.endsWith('.sentry.io'));
- });
-
- expect(sentryFetchSpans).toHaveLength(0);
-});
-
-test('Tunnel requests are sent without the cookies of the browser', async ({ page, context, baseURL }) => {
- test.skip(process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE === 'handler', 'The handler variants send the cookies');
+test('forwards events without the cookies of the browser', async ({ page, context, baseURL }) => {
await context.addCookies([{ name: 'session', value: '8f2c1d', url: baseURL }]);
const proxyRequestPromise = waitForRequest('nextjs-16-tunnel', ({ envelope }) =>
envelope[1].some(
([itemHeader, item]) =>
- itemHeader.type === 'event' && (item as Event).exception?.values?.[0]?.value === 'Tunnel cookie test',
+ itemHeader.type === 'event' && (item as Event).exception?.values?.[0]?.value === 'Tunnel route cookie test',
),
);
@@ -138,89 +74,59 @@ test('Tunnel requests are sent without the cookies of the browser', async ({ pag
request =>
request.method() === 'POST' &&
new URL(request.url()).origin === baseURL &&
- (request.postData() ?? '').includes('Tunnel cookie test'),
+ (request.postData() ?? '').includes('Tunnel route cookie test'),
);
await page.evaluate(() => {
setTimeout(() => {
- throw new Error('Tunnel cookie test');
+ throw new Error('Tunnel route cookie test');
});
});
const tunnelRequest = await tunnelRequestPromise;
const proxyRequest = await proxyRequestPromise;
- expect(await page.evaluate(() => document.cookie)).toBe('session=8f2c1d');
- expect((await tunnelRequest.allHeaders()).cookie).toBeUndefined();
+ expect(isTunnelPath(new URL(tunnelRequest.url()).pathname)).toBe(true);
+ // The Vercel rewrite only matches envelope requests.
+ expect((await tunnelRequest.allHeaders())['content-type']).toBe('application/x-sentry-envelope');
+ expect((await tunnelRequest.allHeaders()).cookie).toBe('session=8f2c1d');
expect(proxyRequest.rawProxyRequestHeaders.cookie).toBeUndefined();
+ expect(proxyRequest.rawProxyRequestHeaders['content-type']).toBe('application/x-sentry-envelope');
});
-test.describe('Tunnel route handler', () => {
- test.skip(process.env.NEXT_PUBLIC_E2E_TEST_TUNNEL_MODE !== 'handler', 'Only the handler variants use the handler');
-
- test('forwards events without the cookies of the browser', async ({ page, context, baseURL }) => {
- await context.addCookies([{ name: 'session', value: '8f2c1d', url: baseURL }]);
- const proxyRequestPromise = waitForRequest('nextjs-16-tunnel', ({ envelope }) =>
- envelope[1].some(
- ([itemHeader, item]) =>
- itemHeader.type === 'event' &&
- (item as Event).exception?.values?.[0]?.value === 'Tunnel route handler cookie test',
- ),
- );
-
- await page.goto('/');
- await page.waitForFunction(() => typeof (window as { __SENTRY__?: unknown }).__SENTRY__ === 'object');
- const tunnelRequestPromise = page.waitForRequest(
- request =>
- request.method() === 'POST' &&
- new URL(request.url()).origin === baseURL &&
- (request.postData() ?? '').includes('Tunnel route handler cookie test'),
- );
- await page.evaluate(() => {
- setTimeout(() => {
- throw new Error('Tunnel route handler cookie test');
- });
- });
-
- const tunnelRequest = await tunnelRequestPromise;
- const proxyRequest = await proxyRequestPromise;
-
- expect(new URL(tunnelRequest.url()).search).toBe('');
- expect((await tunnelRequest.allHeaders()).cookie).toBe('session=8f2c1d');
- expect(proxyRequest.rawProxyRequestHeaders.cookie).toBeUndefined();
- expect(proxyRequest.rawProxyRequestHeaders['content-type']).toBe('application/x-sentry-envelope');
+test('does not create server spans for tunnel requests', async ({ page, baseURL }) => {
+ // One listener, so it gets every span that the proxy received before the barrier span.
+ const spansBeforeBarrier: SerializedStreamedSpan[] = [];
+ const barrierSpanPromise = waitForStreamedSpans('nextjs-16-tunnel', spans => {
+ spansBeforeBarrier.push(...spans);
+ return spans.some(span => span.is_segment && span.name === 'GET /api/flush');
});
+ const pageloadTunnelResponsePromise = page.waitForResponse(
+ response =>
+ response.request().method() === 'POST' &&
+ new URL(response.url()).origin === baseURL &&
+ (response.request().postData() ?? '').includes('pageload'),
+ );
- test('does not create server spans for tunnel requests', async ({ page, baseURL }) => {
- // One listener, so it gets every span that the proxy received before the barrier span.
- const spansBeforeBarrier: SerializedStreamedSpan[] = [];
- const barrierSpanPromise = waitForStreamedSpans('nextjs-16-tunnel', spans => {
- spansBeforeBarrier.push(...spans);
- return spans.some(span => span.is_segment && span.name === 'GET /api/flush');
- });
- const pageloadTunnelResponsePromise = page.waitForResponse(
- response =>
- response.request().method() === 'POST' &&
- new URL(response.url()).origin === baseURL &&
- (response.request().postData() ?? '').includes('pageload'),
- );
-
- await page.goto('/');
- await pageloadTunnelResponsePromise;
- // Flush the edge client of the edge tunnel route (a 405 on the Node.js one), then the Node.js client twice:
- // the first flush sends the tunnel spans, the second one the barrier span of the first flush.
- await page.request.get('/sentry-tunnel');
- await page.request.get('/api/flush');
- await page.request.get('/api/flush');
- await barrierSpanPromise;
-
- const postSpans = spansBeforeBarrier.filter(
- span => span.name.startsWith('POST') || getStringAttribute(span, HTTP_REQUEST_METHOD) === 'POST',
- );
- const ingestSpans = spansBeforeBarrier.filter(
- span =>
- getSpanOp(span) === 'http.client' && !!getStringAttribute(span, URL_FULL)?.startsWith('http://localhost:3031/'),
- );
- expect(postSpans).toEqual([]);
- expect(ingestSpans).toEqual([]);
- });
+ await page.goto('/');
+ await pageloadTunnelResponsePromise;
+ // The first flush sends the tunnel spans, the second one the barrier span of the first flush.
+ await page.request.get('/api/flush');
+ await page.request.get('/api/flush');
+ await barrierSpanPromise;
+
+ // The middleware span of the page request arrived, so the ones of the tunnel requests would have too.
+ expect(spansBeforeBarrier.some(span => span.name === 'middleware GET')).toBe(true);
+
+ const postSpans = spansBeforeBarrier.filter(
+ span =>
+ span.name.includes('POST') ||
+ getStringAttribute(span, HTTP_REQUEST_METHOD) === 'POST' ||
+ getStringAttribute(span, 'http.method') === 'POST',
+ );
+ const ingestSpans = spansBeforeBarrier.filter(
+ span =>
+ getSpanOp(span) === 'http.client' && !!getStringAttribute(span, URL_FULL)?.startsWith('http://localhost:3031/'),
+ );
+ expect(postSpans).toEqual([]);
+ expect(ingestSpans).toEqual([]);
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-handler/edge/sentry-tunnel/route.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-handler/edge/sentry-tunnel/route.ts
deleted file mode 100644
index 4eeb13efd97f..000000000000
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-handler/edge/sentry-tunnel/route.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import * as Sentry from '@sentry/nextjs';
-import { createSentryTunnelRoute } from '@sentry/nextjs/tunnel';
-import { SENTRY_DSN } from '@/sentry-dsn';
-
-export const { POST } = createSentryTunnelRoute({ allowedDsns: [SENTRY_DSN] });
-
-// Each edge route has its own SDK client, so the tests flush this one here.
-export async function GET(): Promise {
- await Sentry.flush();
- return new Response(null, { status: 204 });
-}
-
-export const runtime = 'edge';
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-handler/node/sentry-tunnel/route.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-handler/node/sentry-tunnel/route.ts
deleted file mode 100644
index 23c975fb750d..000000000000
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-handler/node/sentry-tunnel/route.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { POST } from '@sentry/nextjs/tunnel';
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-middleware/middleware.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-middleware/middleware.ts
new file mode 100644
index 000000000000..49cfd8ee0af2
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/tunnel-middleware/middleware.ts
@@ -0,0 +1,16 @@
+import * as Sentry from '@sentry/nextjs';
+import { NextResponse } from 'next/server';
+import type { NextRequest } from 'next/server';
+
+export async function middleware(request: NextRequest) {
+ const tunnelResponse = Sentry.handleTunnelRequestIfMatched(request);
+ if (tunnelResponse) {
+ return tunnelResponse;
+ }
+
+ return NextResponse.next();
+}
+
+export const config = {
+ matcher: '/:path*',
+};
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/worker.ts b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/worker.ts
index 522d8c460dfd..43ae875d27cb 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/worker.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/worker.ts
@@ -5,9 +5,9 @@ import handler from './.open-next/worker.js';
export default Sentry.withSentry(
() => ({
environment: 'qa', // dynamic sampling bias to keep transactions
- dsn: 'https://public@o12345.ingest.us.sentry.io/67890',
- // Sends the server spans to the proxy server, so the tests see whether a tunnel request was sampled.
- tunnel: 'http://localhost:3031/',
+ // Sends the server spans and the tunnel requests to the proxy server, so the tests see whether a tunnel request was
+ // sampled.
+ dsn: 'http://public@localhost:3031/1337',
tracesSampleRate: 1.0,
}),
handler,
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/package.json b/dev-packages/e2e-tests/test-applications/nextjs-16/package.json
index aa1116924f00..f5cc1df86d99 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16/package.json
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16/package.json
@@ -25,7 +25,9 @@
"test:build-latest:cloudflare": "pnpm install && pnpm add next@latest && opennextjs-cloudflare build --config wrangler.opennext.jsonc",
"start:cloudflare": "opennextjs-cloudflare preview --config wrangler.opennext.jsonc --var \"E2E_TEST_DSN:$E2E_TEST_DSN\"",
"test:build:vinext": "pnpm install && pnpm add react@19.3.1 react-dom@19.3.1 && npm pkg set type=module && vinext build",
- "test:assert:vinext": "VINEXT=1 pnpm test:prod"
+ "test:assert:vinext": "VINEXT=1 pnpm test:prod",
+ "test:build:bun": "pnpm install && bun --bun ./node_modules/next/dist/bin/next build",
+ "test:build:deno": "pnpm install && deno run -A ./node_modules/next/dist/bin/next build"
},
"//": "Pin `ioredis` to 5.10.1: it's the last version before the driver publishes its own native diagnostics channels; orchestrion's config covers `ioredis <5.11.0`.",
"dependencies": {
@@ -87,7 +89,8 @@
{
"build-command": "pnpm install",
"label": "nextjs-16 (webpack, development)",
- "assert-command": "pnpm test:dev-webpack"
+ "assert-command": "pnpm test:dev-webpack",
+ "test-shards": 2
},
{
"build-command": "pnpm test:build-latest-webpack",
@@ -97,7 +100,8 @@
{
"build-command": "pnpm install && pnpm add next@latest",
"label": "nextjs-16 (latest, webpack, development)",
- "assert-command": "pnpm test:dev-webpack"
+ "assert-command": "pnpm test:dev-webpack",
+ "test-shards": 2
},
{
"build-command": "pnpm test:build-latest",
@@ -111,6 +115,7 @@
},
{
"runtime": "bun",
+ "build-command": "pnpm test:build:bun",
"assert-command": "pnpm test:prod",
"label": "nextjs-16 (bun)"
},
@@ -119,6 +124,13 @@
"build-command": "pnpm test:build:cloudflare",
"assert-command": "pnpm test:prod",
"label": "nextjs-16 (cloudflare)"
+ },
+ {
+ "runtime": "deno",
+ "build-command": "pnpm test:build:deno",
+ "assert-command": "pnpm test:prod",
+ "deno-version": "v2.9.0",
+ "label": "nextjs-16 (deno)"
}
],
"optionalVariants": [
@@ -128,12 +140,6 @@
"assert-command": "pnpm test:prod",
"label": "nextjs-16 (cloudflare, latest)"
},
- {
- "runtime": "deno",
- "assert-command": "pnpm test:prod",
- "deno-version": "v2.9.0",
- "label": "nextjs-16 (deno)"
- },
{
"build-command": "pnpm test:build:vinext",
"assert-command": "pnpm test:assert:vinext",
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/nextjs-16/playwright.config.mjs
index 0d18ae12efc4..7611f4a90d98 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16/playwright.config.mjs
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16/playwright.config.mjs
@@ -8,7 +8,7 @@ if (!testEnv) {
const productionStartCommands = {
node: 'pnpm next start -p 3030',
bun: 'bun --bun ./node_modules/next/dist/bin/next start -p 3030',
- deno: 'deno run -A ./node_modules/next/dist/bin/next start -p 3030',
+ deno: 'deno run -A --conditions=deno ./node_modules/next/dist/bin/next start -p 3030',
cloudflare: 'pnpm start:cloudflare --port 3030',
};
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/sentry.server.config.ts b/dev-packages/e2e-tests/test-applications/nextjs-16/sentry.server.config.ts
index f0ec19dd256d..0bf1422aa2b4 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16/sentry.server.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16/sentry.server.config.ts
@@ -1,5 +1,3 @@
-import { bunHttpServerIntegration, fetchIntegration as bunFetchIntegration } from '@sentry/bun';
-import { fetchIntegration as denoFetchIntegration } from '@sentry/deno';
import * as Sentry from '@sentry/nextjs';
import { Log } from '@sentry/nextjs';
@@ -11,15 +9,7 @@ Sentry.init({
_flushInterval: 100,
tracePropagationTargets: ['http://localhost:3030/propagation/test-outgoing-fetch/check'],
// debug: true,
- integrations: [
- Sentry.vercelAIIntegration(),
- Sentry.nodeRuntimeMetricsIntegration({ collectionIntervalMs: 1_000 }),
- // Bun does not emit the `node:http` diagnostics channel the Node SDK uses to isolate incoming requests, so each
- // request would otherwise share one trace. Next.js emits its own server spans, hence `spans: false`.
- ...(process.versions.bun ? [bunHttpServerIntegration({ spans: false }), bunFetchIntegration()] : []),
- // The `fetch` of Deno is not undici, so the Node SDK does not see outgoing requests.
- ...(process.versions.deno ? [denoFetchIntegration()] : []),
- ],
+ integrations: [Sentry.vercelAIIntegration(), Sentry.nodeRuntimeMetricsIntegration({ collectionIntervalMs: 1_000 })],
// Verify Log type is available
beforeSendLog(log: Log) {
return log;
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/tests/route-handler.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-16/tests/route-handler.test.ts
index 31936d435283..2cd08fbd2637 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16/tests/route-handler.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16/tests/route-handler.test.ts
@@ -1,5 +1,5 @@
import test, { expect } from '@playwright/test';
-import { getSpanOp, waitForError, waitForStreamedSpan } from '@sentry-internal/test-utils';
+import { getRuntime, getSpanOp, waitForError, waitForStreamedSpan } from '@sentry-internal/test-utils';
import { isTurbopackDevMode } from './isDevMode';
test('Should create a span for node route handlers', async ({ request }) => {
@@ -61,6 +61,7 @@ test('Should report an error with a parameterized span name for a throwing route
// Error should carry the parameterized transaction name
expect(errorEvent.transaction).toBe('GET /route-handler/[xoxo]/error');
+ expect(errorEvent.contexts?.runtime?.name).toBe(getRuntime());
// Span should have parameterized name and an error status
expect(span.name).toBe('GET /route-handler/[xoxo]/error');
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/tests/worker-bundle.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-16/tests/worker-bundle.test.ts
index af16d1add37d..75354eae915b 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16/tests/worker-bundle.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16/tests/worker-bundle.test.ts
@@ -25,7 +25,7 @@ test('worker bundle does not contain the orchestrion bundler plugins', () => {
);
expect(serverFiles.length).toBeGreaterThan(0);
- const markers = ['code-transformer-bundler-plugins', '__codeTransformerWebpackDiagnostics'];
+ const markers = ['__codeTransformerWebpackDiagnostics'];
// The markers must still exist in the installed plugin build.
// If upstream renames them, this fails instead of letting the leak check below pass.
@@ -56,7 +56,7 @@ function readOrchestrionPluginGraphSources(): string[] {
const entrySource = fs.readFileSync(pluginEntry, 'utf8');
return [
entrySource,
- ...[...entrySource.matchAll(/require\('(\.\.?\/[^']+)'\)/g)].map(([, specifier]) =>
+ ...[...entrySource.matchAll(/require\(['"](\.\.?\/[^'"]+)['"]\)/g)].map(([, specifier]) =>
fs.readFileSync(path.resolve(path.dirname(pluginEntry), specifier), 'utf8'),
),
];
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/vite.config.mts b/dev-packages/e2e-tests/test-applications/nextjs-16/vite.config.mts
index 06fc7d855003..d816a23bc9cf 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-16/vite.config.mts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-16/vite.config.mts
@@ -7,6 +7,13 @@ import { defineConfig } from 'vite';
export default defineConfig({
plugins: [vinext()],
// `app/api/d1` imports `@opennextjs/cloudflare` for the OpenNext variants. Its `import()` of a computed specifier can
- // not be bundled.
- environments: { rsc: { resolve: { external: ['@opennextjs/cloudflare'] } } },
+ // not be bundled. On Bun, `@sentry/nextjs` is external so that Bun resolves it at run time and loads its Bun entry.
+ // Node.js would load its CommonJS build from ESM, which hides the re-exported names.
+ environments: {
+ rsc: {
+ resolve: {
+ external: ['@opennextjs/cloudflare', ...(process.env.RUNTIME === 'bun' ? ['@sentry/nextjs'] : [])],
+ },
+ },
+ },
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts
index 554c41fc3108..903ebdb3a358 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts
@@ -1,6 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as assert from 'assert/strict';
+import { findSourceMapFiles } from '@sentry-internal/test-utils';
const nextPackageJson = require('next/package.json');
const nextjsVersion = nextPackageJson.version;
@@ -41,12 +42,9 @@ const getLatestNextVersion = async () => {
assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[\.\.\.parameters\]/);
assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[parameter\]/);
- // Read the contents of the directory
- const files = fs.readdirSync(path.join(process.cwd(), '.next', 'static'));
- const mapFiles = files.filter(file => path.extname(file) === '.map');
- if (mapFiles.length > 0) {
- throw new Error(
- 'Client bundle .map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!',
- );
- }
+ assert.deepEqual(
+ findSourceMapFiles({ outputDir: path.join('.next', 'static') }),
+ [],
+ 'Client bundle .map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!',
+ );
})();
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-errors.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-errors.test.ts
index 70a8cb313b05..ffc53c210046 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-errors.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-errors.test.ts
@@ -29,9 +29,9 @@ test('Sends a client-side exception to Sentry', async ({ page }) => {
expect(errorEvent.transaction).toEqual('/');
expect(errorEvent.contexts?.trace).toEqual({
- // Next.js >= 15 propagates a trace ID to the client via a meta tag. Also, only dev mode emits a meta tag because
- // the requested page is static and only in dev mode SSR is kicked off.
- parent_span_id: nextjsMajor >= 15 && isDevMode ? expect.any(String) : undefined,
+ // The server sends the trace in a `Server-Timing` header, except with a document a shared cache may store. In
+ // production the requested page is static, so only dev mode, which renders it per request, connects the pageload.
+ parent_span_id: isDevMode ? expect.any(String) : undefined,
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts
index fe912c78b223..98c109253a27 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts
@@ -11,9 +11,6 @@ import { isDevMode } from './isDevMode';
const nextPackageJson = require('next/package.json');
test('Sends a pageload span', async ({ page }) => {
- const nextjsVersion = nextPackageJson.version;
- const nextjsMajor = Number(nextjsVersion.split('.')[0]);
-
const pageloadSpanPromise = waitForStreamedSpan('nextjs-app-dir', span => {
return getSpanOp(span) === 'pageload' && span.name === '/' && span.is_segment;
});
@@ -22,9 +19,9 @@ test('Sends a pageload span', async ({ page }) => {
const span = await pageloadSpanPromise;
- // Next.js >= 15 propagates a trace ID to the client via a meta tag. Also, only dev mode emits a meta tag because
- // the requested page is static and only in dev mode SSR is kicked off.
- if (nextjsMajor >= 15 && isDevMode) {
+ // The server sends the trace in a `Server-Timing` header, except with a document a shared cache may store. In
+ // production the requested page is static, so only dev mode, which renders it per request, connects the pageload.
+ if (isDevMode) {
expect(span.parent_span_id).toEqual(expect.any(String));
} else {
expect(span.parent_span_id).toBeUndefined();
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel-tracer-provider.ts b/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel-tracer-provider.ts
new file mode 100644
index 000000000000..dd56ed7a742a
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel-tracer-provider.ts
@@ -0,0 +1,22 @@
+import { context, propagation, trace } from '@opentelemetry/api';
+import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
+import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
+import type { Resource } from '@opentelemetry/resources';
+import type { SpanExporter } from '@opentelemetry/sdk-trace';
+import { BatchSpanProcessor, TracerProvider } from '@opentelemetry/sdk-trace';
+
+// OpenTelemetry SDK v3 has no `NodeTracerProvider.register()`, so the app registers the tracer
+// provider, context manager and propagator itself. The OTel SDK v2 variant replaces this file with
+// `otel-v2/otel-tracer-provider.ts`.
+export function registerTracerProvider(exporter: SpanExporter, resource: Resource): void {
+ trace.setGlobalTracerProvider(
+ new TracerProvider({
+ resource,
+ spanProcessors: [new BatchSpanProcessor({ exporter, scheduledDelayMillis: 100 })],
+ }),
+ );
+ context.setGlobalContextManager(new AsyncLocalStorageContextManager().enable());
+ propagation.setGlobalPropagator(
+ new CompositePropagator({ propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()] }),
+ );
+}
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel-v2/otel-tracer-provider.ts b/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel-v2/otel-tracer-provider.ts
new file mode 100644
index 000000000000..3af449a59158
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel-v2/otel-tracer-provider.ts
@@ -0,0 +1,11 @@
+import type { Resource } from '@opentelemetry/resources';
+import type { SpanExporter } from '@opentelemetry/sdk-trace-base';
+import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
+import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
+
+export function registerTracerProvider(exporter: SpanExporter, resource: Resource): void {
+ new NodeTracerProvider({
+ resource,
+ spanProcessors: [new BatchSpanProcessor(exporter, { scheduledDelayMillis: 100 })],
+ }).register();
+}
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel.server.config.ts b/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel.server.config.ts
index 0ee1bc170f31..33d2bef4f832 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel.server.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-otlp/otel.server.config.ts
@@ -1,9 +1,8 @@
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { resourceFromAttributes } from '@opentelemetry/resources';
-import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
-import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { getOtlpTracesEndpoint } from '@sentry/nextjs';
import { OTLP_RECEIVER_PORT, startOtlpReceiver } from './otel-receiver';
+import { registerTracerProvider } from './otel-tracer-provider';
// Next.js can run `register()` more than once in dev, which would leave a second receiver fighting
// for the port and a second set of providers losing the race to register globally.
@@ -27,13 +26,8 @@ if (!globalWithOtelFlag.__otelRegistered) {
// The app owns tracing: this registers the global tracer provider, context manager and
// propagator. Sentry is initialized afterwards with `enableOpenTelemetrySetup: false` so it does
// not contend for any of them.
- new NodeTracerProvider({
+ registerTracerProvider(
+ new OTLPTraceExporter({ url: `${otlpBaseUrl}/v1/traces`, headers: otlpTracesEndpoint.headers }),
resource,
- spanProcessors: [
- new BatchSpanProcessor(
- new OTLPTraceExporter({ url: `${otlpBaseUrl}/v1/traces`, headers: otlpTracesEndpoint.headers }),
- { scheduledDelayMillis: 100 },
- ),
- ],
- }).register();
+ );
}
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-otlp/package.json b/dev-packages/e2e-tests/test-applications/nextjs-otlp/package.json
index 64c289e9439a..11a1be9b3bdd 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-otlp/package.json
+++ b/dev-packages/e2e-tests/test-applications/nextjs-otlp/package.json
@@ -14,16 +14,18 @@
"test:dev": "TEST_ENV=development playwright test",
"test:dev-webpack": "TEST_ENV=development-webpack playwright test",
"test:build": "pnpm install && pnpm build",
+ "test:build:otel-v2": "pnpm remove @opentelemetry/context-async-hooks @opentelemetry/core @opentelemetry/sdk-trace && pnpm add @opentelemetry/api@1.9.1 @opentelemetry/exporter-trace-otlp-http@^0.220.0 @opentelemetry/resources@^2.9.0 @opentelemetry/sdk-trace-base@^2.9.0 @opentelemetry/sdk-trace-node@^2.9.0 && pnpm dedupe && cp otel-v2/otel-tracer-provider.ts otel-tracer-provider.ts && pnpm build",
"test:build-webpack": "pnpm install && pnpm build-webpack",
"test:assert": "pnpm test:prod && pnpm test:dev",
"test:assert-webpack": "pnpm test:prod && pnpm test:dev-webpack"
},
"dependencies": {
- "@opentelemetry/api": "^1.9.1",
- "@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
- "@opentelemetry/resources": "^2.9.0",
- "@opentelemetry/sdk-trace-base": "^2.9.0",
- "@opentelemetry/sdk-trace-node": "^2.9.0",
+ "@opentelemetry/api": "^1.10.0",
+ "@opentelemetry/context-async-hooks": "^3.0.0",
+ "@opentelemetry/core": "^3.0.0",
+ "@opentelemetry/exporter-trace-otlp-http": "^0.300.0",
+ "@opentelemetry/resources": "^3.0.0",
+ "@opentelemetry/sdk-trace": "^3.0.0",
"@sentry/core": "file:../../packed/sentry-core-packed.tgz",
"@sentry/nextjs": "file:../../packed/sentry-nextjs-packed.tgz",
"next": "16.3.0",
@@ -46,6 +48,11 @@
"build-command": "pnpm test:build-webpack",
"label": "nextjs-otlp (webpack)",
"assert-command": "pnpm test:assert-webpack"
+ },
+ {
+ "build-command": "pnpm test:build:otel-v2",
+ "assert-command": "pnpm test:assert",
+ "label": "nextjs-otlp (OTel SDK v2)"
}
]
}
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-otlp/tsconfig.json b/dev-packages/e2e-tests/test-applications/nextjs-otlp/tsconfig.json
index cc9ed39b5aa2..f1fb9c3599e1 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-otlp/tsconfig.json
+++ b/dev-packages/e2e-tests/test-applications/nextjs-otlp/tsconfig.json
@@ -23,5 +23,5 @@
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".next/dev/types/**/*.ts", "**/*.mts"],
- "exclude": ["node_modules"]
+ "exclude": ["node_modules", "otel-v2"]
}
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/assert-build.ts b/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/assert-build.ts
index be7beeeb94e6..1ef943a854bb 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/assert-build.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/assert-build.ts
@@ -1,6 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as assert from 'assert/strict';
+import { findSourceMapFiles } from '@sentry-internal/test-utils';
const nextPackageJson = require('next/package.json');
const nextjsVersion = nextPackageJson.version;
@@ -33,12 +34,9 @@ const getLatestNextVersion = async () => {
);
}
- // Read the contents of the directory
- const files = fs.readdirSync(path.join(process.cwd(), '.next', 'static'));
- const mapFiles = files.filter(file => path.extname(file) === '.map');
- if (mapFiles.length > 0) {
- throw new Error(
- 'Client bundle .map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!',
- );
- }
+ assert.deepEqual(
+ findSourceMapFiles({ outputDir: path.join('.next', 'static') }),
+ [],
+ 'Client bundle .map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!',
+ );
})();
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/tests/transactions.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/tests/transactions.test.ts
index 6529185e4f79..dd75989aff1e 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/tests/transactions.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-pages-dir/tests/transactions.test.ts
@@ -2,12 +2,7 @@ import { expect, test } from '@playwright/test';
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
import { isDevMode } from './isDevMode';
-const nextPackageJson = require('next/package.json');
-
test('Sends a pageload span', async ({ page }) => {
- const nextjsVersion = nextPackageJson.version;
- const nextjsMajor = Number(nextjsVersion.split('.')[0]);
-
const pageloadSpanPromise = waitForStreamedSpan('nextjs-pages-dir', span => {
return getSpanOp(span) === 'pageload' && span.name === '/' && span.is_segment;
});
@@ -16,13 +11,9 @@ test('Sends a pageload span', async ({ page }) => {
const span = await pageloadSpanPromise;
- // Next.js >= 15 propagates a trace ID to the client via a meta tag. Also, only dev mode emits a meta tag because
- // the requested page is static and only in dev mode SSR is kicked off.
- if (nextjsMajor >= 15 && isDevMode) {
- expect(span.parent_span_id).toEqual(expect.any(String));
- } else {
- expect(span.parent_span_id).toBeUndefined();
- }
+ // The server sends the trace in a `Server-Timing` header. The page is static, but the pages router serves it
+ // without a `Cache-Control` that lets a shared cache store it, so the header goes out in production too.
+ expect(span.parent_span_id).toEqual(expect.any(String));
expect(span.span_id).toEqual(expect.stringMatching(/[a-f0-9]{16}/));
expect(span.trace_id).toEqual(expect.stringMatching(/[a-f0-9]{32}/));
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/assert-build.ts b/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/assert-build.ts
index 116dbd875baa..1f02a4bc61a2 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/assert-build.ts
+++ b/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/assert-build.ts
@@ -7,6 +7,9 @@ import {
getSourcemapSources,
getChunkUploadPosts,
getAssembleRequests,
+ findSourceMapFiles,
+ findSourceMappingUrlComments,
+ getRuntime,
} from '@sentry-internal/test-utils';
const requests = loadMockServerResults();
@@ -29,6 +32,12 @@ assert.ok(
'Expected at least one chunk upload with a non-empty body',
);
+// The `sentry` CLI adds the runtime that runs it to its User-Agent, for example `bun/1.4.2`.
+const runtime = getRuntime();
+for (const req of chunkPosts) {
+ assert.match(req.requestHeaders['user-agent'] ?? '', new RegExp(` ${runtime}/`), `Expected ${runtime} to upload`);
+}
+
// Release endpoint was called
assert.ok(
requests.some(r => r.url?.includes('/releases/')),
@@ -76,4 +85,15 @@ for (const req of assembleReqs) {
assert.ok((req.assembleBody?.chunks?.length ?? 0) > 0, 'Expected assemble request to have chunk checksums');
}
+// The browser loads everything under `.next/static`, so a map left there hands out the source.
+if (process.env.E2E_DELETE_SOURCEMAPS) {
+ const staticDir = '.next/static';
+ assert.deepEqual(findSourceMapFiles({ outputDir: staticDir }), [], `Expected no source maps in ${staticDir}`);
+ assert.deepEqual(
+ findSourceMappingUrlComments({ outputDir: staticDir }),
+ [],
+ `Expected no sourceMappingURL comments in ${staticDir}`,
+ );
+}
+
console.log('All sourcemap upload assertions passed!');
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/next.config.js b/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/next.config.js
index 69a0a61a9388..1c63cca05558 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/next.config.js
+++ b/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/next.config.js
@@ -12,7 +12,8 @@ module.exports = withSentryConfig(nextConfig, {
name: 'test-release',
},
sourcemaps: {
- deleteSourcemapsAfterUpload: false,
+ // The delete variants use the SDK default, which removes the client maps after the upload.
+ deleteSourcemapsAfterUpload: process.env.E2E_DELETE_SOURCEMAPS ? undefined : false,
},
debug: true,
});
diff --git a/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/package.json b/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/package.json
index 993eef30d1ee..6eb21bda4d45 100644
--- a/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/package.json
+++ b/dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/package.json
@@ -3,10 +3,15 @@
"version": "0.1.0",
"private": true,
"scripts": {
- "build": "node start-mock-sentry-server.mjs & next build > .tmp_build_stdout 2> .tmp_build_stderr; BUILD_EXIT=$?; kill %1 2>/dev/null; exit $BUILD_EXIT",
+ "build": "node start-mock-sentry-server.mjs & next build ${E2E_NEXT_WEBPACK:+--webpack} > .tmp_build_stdout 2> .tmp_build_stderr; BUILD_EXIT=$?; kill %1 2>/dev/null; exit $BUILD_EXIT",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
- "test:assert": "pnpm ts-node --script-mode assert-build.ts"
+ "test:assert": "pnpm ts-node --script-mode assert-build.ts",
+ "test:build:delete": "pnpm install && E2E_DELETE_SOURCEMAPS=1 pnpm build",
+ "test:build:delete-webpack": "pnpm install && E2E_DELETE_SOURCEMAPS=1 E2E_NEXT_WEBPACK=1 pnpm build",
+ "test:build:delete-bun": "pnpm install && E2E_DELETE_SOURCEMAPS=1 bun --bun run build",
+ "test:build:delete-webpack-bun": "pnpm install && E2E_DELETE_SOURCEMAPS=1 E2E_NEXT_WEBPACK=1 bun --bun run build",
+ "test:assert:delete": "E2E_DELETE_SOURCEMAPS=1 pnpm test:assert"
},
"dependencies": {
"@sentry/nextjs": "file:../../packed/sentry-nextjs-packed.tgz",
@@ -22,5 +27,31 @@
"@types/react": "^19",
"@types/react-dom": "^19",
"ts-node": "10.9.1"
+ },
+ "sentryTest": {
+ "variants": [
+ {
+ "build-command": "pnpm test:build:delete",
+ "assert-command": "pnpm test:assert:delete",
+ "label": "nextjs-sourcemaps (delete, turbopack)"
+ },
+ {
+ "build-command": "pnpm test:build:delete-webpack",
+ "assert-command": "pnpm test:assert:delete",
+ "label": "nextjs-sourcemaps (delete, webpack)"
+ },
+ {
+ "runtime": "bun",
+ "build-command": "pnpm test:build:delete-bun",
+ "assert-command": "pnpm test:assert:delete",
+ "label": "nextjs-sourcemaps (delete, turbopack, bun)"
+ },
+ {
+ "runtime": "bun",
+ "build-command": "pnpm test:build:delete-webpack-bun",
+ "assert-command": "pnpm test:assert:delete",
+ "label": "nextjs-sourcemaps (delete, webpack, bun)"
+ }
+ ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/index.html b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/index.html
new file mode 100644
index 000000000000..61742e1966a5
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/index.html
@@ -0,0 +1,20 @@
+
+
+
+
+ Nitro Tunnel E2E Test
+
+
+
+
+
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/instrument.mjs b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/instrument.mjs
new file mode 100644
index 000000000000..5bc7c75f8cd1
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/instrument.mjs
@@ -0,0 +1,7 @@
+import * as Sentry from '@sentry/nitro';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [Sentry.serveTunnelIntegration()],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/package.json b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/package.json
new file mode 100644
index 000000000000..162068d34d3e
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "nitro-3-tunnel",
+ "version": "1.0.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "build": "vite build",
+ "start": "PORT=3030 NODE_OPTIONS='--import ./instrument.mjs' node .output/server/index.mjs",
+ "clean": "npx rimraf node_modules pnpm-lock.yaml .output",
+ "test:build": "pnpm install && pnpm build",
+ "test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
+ },
+ "dependencies": {
+ "@sentry/browser": "latest || *",
+ "@sentry/nitro": "latest || *"
+ },
+ "devDependencies": {
+ "@playwright/test": "1.64.1",
+ "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
+ "nitro": "^3.0.260522-beta",
+ "vite": "latest"
+ }
+}
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/playwright.config.mjs
new file mode 100644
index 000000000000..24dd4d9ac31d
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/playwright.config.mjs
@@ -0,0 +1,8 @@
+import { getPlaywrightConfig } from '@sentry-internal/test-utils';
+
+export default getPlaywrightConfig({
+ startCommand:
+ process.env.TEST_ENV === 'development'
+ ? `PORT=3030 NODE_OPTIONS='--import ./instrument.mjs' pnpm exec vite dev --port 3030`
+ : `pnpm start`,
+});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/pnpm-workspace.yaml
new file mode 100644
index 000000000000..c6eea3e5ab0a
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/pnpm-workspace.yaml
@@ -0,0 +1,3 @@
+minimumReleaseAge: 0
+overrides:
+ 'unstorage': '2.0.0-alpha.7'
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/api/anchor.ts b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/api/anchor.ts
new file mode 100644
index 000000000000..7f820ccd5ef3
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/api/anchor.ts
@@ -0,0 +1,3 @@
+import { defineHandler } from 'nitro/h3';
+
+export default defineHandler(() => ({ ok: true }));
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/api/error.ts b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/api/error.ts
new file mode 100644
index 000000000000..8630745dc6f1
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/api/error.ts
@@ -0,0 +1,5 @@
+import { defineHandler } from 'nitro/h3';
+
+export default defineHandler(() => {
+ throw new Error('Tunnel test error');
+});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/middleware/auth.ts b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/middleware/auth.ts
new file mode 100644
index 000000000000..5052cc94842f
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/server/middleware/auth.ts
@@ -0,0 +1,7 @@
+import { defineHandler, HTTPError } from 'nitro/h3';
+
+export default defineHandler(event => {
+ if (event.req.method === 'POST') {
+ throw new HTTPError({ status: 401, statusText: 'blocked by user auth' });
+ }
+});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/start-event-proxy.mjs
new file mode 100644
index 000000000000..fc9c49b19b09
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/start-event-proxy.mjs
@@ -0,0 +1,6 @@
+import { startEventProxyServer } from '@sentry-internal/test-utils';
+
+startEventProxyServer({
+ port: 3031,
+ proxyServerName: 'nitro-3-tunnel',
+});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/tests/tunnel.test.ts
new file mode 100644
index 000000000000..713764759c82
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/tests/tunnel.test.ts
@@ -0,0 +1,3 @@
+import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';
+
+runManagedTunnelSuite({ appName: 'nitro-3-tunnel', basePath: '/app' });
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/vite.config.ts b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/vite.config.ts
new file mode 100644
index 000000000000..06e9ca9776f7
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nitro-3-tunnel/vite.config.ts
@@ -0,0 +1,8 @@
+import { withSentryConfig } from '@sentry/nitro';
+import { nitro } from 'nitro/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ // @ts-expect-error The Nitro plugin's types don't accept the config `withSentryConfig` returns
+ plugins: [nitro(withSentryConfig({ serverDir: './server', baseURL: '/app/' }))],
+});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/instrument.mjs b/dev-packages/e2e-tests/test-applications/nitro-3/instrument.mjs
index c5c0fbd3d966..53b80d309a5b 100644
--- a/dev-packages/e2e-tests/test-applications/nitro-3/instrument.mjs
+++ b/dev-packages/e2e-tests/test-applications/nitro-3/instrument.mjs
@@ -2,8 +2,7 @@ import * as Sentry from '@sentry/nitro';
Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
- dsn: process.env.E2E_TEST_TUNNEL ? 'http://public@localhost:3031/1337' : process.env.E2E_TEST_DSN,
+ dsn: process.env.E2E_TEST_DSN,
tunnel: `http://localhost:3031/`, // proxy server
- integrations: process.env.E2E_TEST_TUNNEL ? [Sentry.serveTunnelIntegration()] : [],
tracesSampleRate: 1,
});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/package.json b/dev-packages/e2e-tests/test-applications/nitro-3/package.json
index 220276c63139..c8103a134e82 100644
--- a/dev-packages/e2e-tests/test-applications/nitro-3/package.json
+++ b/dev-packages/e2e-tests/test-applications/nitro-3/package.json
@@ -9,10 +9,7 @@
"clean": "npx rimraf node_modules pnpm-lock.yaml .output",
"test": "playwright test",
"test:build": "pnpm install && pnpm build",
- "test:assert": "pnpm test",
- "test:build:tunnel-basepath": "pnpm install && E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm build",
- "test:assert:tunnel-basepath": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app playwright test tunnel",
- "test:assert:tunnel-basepath-dev": "TEST_ENV=development E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app playwright test tunnel"
+ "test:assert": "pnpm test"
},
"dependencies": {
"@sentry/browser": "latest || *",
@@ -21,24 +18,10 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@sentry/core": "latest || *",
"nitro": "^3.0.260522-beta",
"rolldown": "latest",
"vite": "latest"
- },
- "sentryTest": {
- "variants": [
- {
- "build-command": "pnpm test:build:tunnel-basepath",
- "assert-command": "pnpm test:assert:tunnel-basepath",
- "label": "nitro-3 (tunnel-basepath)"
- },
- {
- "build-command": "pnpm install",
- "assert-command": "pnpm test:assert:tunnel-basepath-dev",
- "label": "nitro-3 (tunnel-basepath-dev)"
- }
- ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/server/middleware/test.ts b/dev-packages/e2e-tests/test-applications/nitro-3/server/middleware/test.ts
index 0120ae6ce24e..92d8f80c3756 100644
--- a/dev-packages/e2e-tests/test-applications/nitro-3/server/middleware/test.ts
+++ b/dev-packages/e2e-tests/test-applications/nitro-3/server/middleware/test.ts
@@ -1,11 +1,6 @@
-import { defineHandler, getQuery, HTTPError, setResponseHeader } from 'nitro/h3';
+import { defineHandler, getQuery, setResponseHeader } from 'nitro/h3';
export default defineHandler(event => {
- // The tunnel variant checks that the managed tunnel answers before an auth middleware like this one.
- if (process.env.E2E_TEST_TUNNEL && event.req.method === 'POST' && event.req.headers.get('x-auth') !== 'ok') {
- throw new HTTPError({ status: 401, statusText: 'blocked by user auth' });
- }
-
setResponseHeader(event, 'x-sentry-test-middleware', 'executed');
const query = getQuery(event);
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/src/main.ts b/dev-packages/e2e-tests/test-applications/nitro-3/src/main.ts
index d09a43e411ed..d27d0ba1763a 100644
--- a/dev-packages/e2e-tests/test-applications/nitro-3/src/main.ts
+++ b/dev-packages/e2e-tests/test-applications/nitro-3/src/main.ts
@@ -1,18 +1,10 @@
import * as Sentry from '@sentry/browser';
-declare const __E2E_TEST_TUNNEL__: boolean;
-declare const __E2E_TEST_BASE_PATH__: string;
-
// Let's us test trace propagation
Sentry.init({
environment: 'qa',
- dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
- // Plain Nitro has no client SDK to pass `baseURL` on, so the browser names it. The server picks it up itself.
- tunnel: __E2E_TEST_TUNNEL__
- ? __E2E_TEST_BASE_PATH__
- ? { basePath: __E2E_TEST_BASE_PATH__ }
- : true
- : 'http://localhost:3031/', // proxy server
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
+ tunnel: 'http://localhost:3031/', // proxy server
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1.0,
});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nitro-3/tests/tunnel.test.ts
deleted file mode 100644
index 9d7cfadaeeb6..000000000000
--- a/dev-packages/e2e-tests/test-applications/nitro-3/tests/tunnel.test.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import { expect, test } from '@playwright/test';
-import {
- isServerSpanAt,
- makeClientReportEnvelope,
- waitForError,
- watchForTunnelSpan,
-} from '@sentry-internal/test-utils';
-import { getTunnelPath } from '@sentry/core';
-import { connect } from 'node:net';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-const BASE_PATH = process.env.E2E_TEST_BASE_PATH ?? '';
-const TUNNEL_PATH = new RegExp(`^${BASE_PATH}/[a-z0-9]{1,7}$`);
-
-test('answers the managed tunnel before the app auth middleware', async ({ page }) => {
- // The variant's auth middleware rejects every other POST.
- expect((await page.request.post(`${BASE_PATH}/api/anything`, { data: 'x' })).status()).toBe(401);
-
- const raceTunnelSpan = watchForTunnelSpan('nitro-3', isServerSpanAt(TUNNEL_PATH));
- const tunnelResponsePromise = page.waitForResponse(
- response => response.request().method() === 'POST' && TUNNEL_PATH.test(new URL(response.url()).pathname),
- );
-
- await page.goto(`${BASE_PATH}/`);
-
- expect((await tunnelResponsePromise).status()).toBe(200);
- expect(
- await raceTunnelSpan(isServerSpanAt(`${BASE_PATH}/api/test-transaction`), () =>
- page.request.get(`${BASE_PATH}/api/test-transaction`),
- ),
- ).toBe('anchor');
-});
-
-test('answers a request to the managed tunnel itself', async ({ request }) => {
- const dsn = 'http://public@localhost:3031/1337';
- const response = await request.post(`${BASE_PATH}${getTunnelPath(dsn)}`, {
- data: makeClientReportEnvelope(dsn),
- headers: { 'Content-Type': 'application/x-sentry-envelope' },
- });
-
- expect(response.status()).toBe(200);
-});
-
-test('does not report a client that drops the connection before the envelope header as an error', async ({
- request,
-}) => {
- const dsn = 'http://public@localhost:3031/1337';
- const firstErrorPromise = waitForError('nitro-3', () => true);
-
- // Part of the envelope header line, without its newline, then the connection drops.
- await new Promise(resolve => {
- const socket = connect(3030, 'localhost', () => {
- socket.write(
- `POST ${BASE_PATH}${getTunnelPath(dsn)} HTTP/1.1\r\nHost: localhost:3030\r\nContent-Type: application/x-sentry-envelope\r\nContent-Length: 1000000\r\n\r\n`,
- );
- socket.write(JSON.stringify({ dsn, padding: 'x'.repeat(1000) }).slice(0, 500));
- setTimeout(() => {
- socket.destroy();
- resolve();
- }, 300);
- });
- });
-
- // Errors are sent in order, so one from the dropped request would arrive before this one.
- await request.get(`${BASE_PATH}/api/test-error`);
-
- const firstError = await firstErrorPromise;
- expect(firstError.exception?.values?.[0]?.value).toBe('This is a test error');
-});
diff --git a/dev-packages/e2e-tests/test-applications/nitro-3/vite.config.ts b/dev-packages/e2e-tests/test-applications/nitro-3/vite.config.ts
index b79a665ba851..bb1593e1dcf3 100644
--- a/dev-packages/e2e-tests/test-applications/nitro-3/vite.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nitro-3/vite.config.ts
@@ -3,10 +3,6 @@ import { nitro } from 'nitro/vite';
import { defineConfig } from 'vite';
export default defineConfig({
- define: {
- __E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
- __E2E_TEST_BASE_PATH__: JSON.stringify(process.env.E2E_TEST_BASE_PATH ?? ''),
- },
plugins: [
nitro(
// FIXME: Nitro plugin has a type issue
@@ -14,7 +10,6 @@ export default defineConfig({
withSentryConfig({
serverDir: './server',
experimental: { tasks: true },
- ...(process.env.E2E_TEST_BASE_PATH && { baseURL: `${process.env.E2E_TEST_BASE_PATH}/` }),
}),
),
],
diff --git a/dev-packages/e2e-tests/test-applications/node-eve/agent/instrumentation/sentry.ts b/dev-packages/e2e-tests/test-applications/node-eve/agent/instrumentation/sentry.ts
index 850b9983ac20..a3196304a0da 100644
--- a/dev-packages/e2e-tests/test-applications/node-eve/agent/instrumentation/sentry.ts
+++ b/dev-packages/e2e-tests/test-applications/node-eve/agent/instrumentation/sentry.ts
@@ -7,5 +7,8 @@ export default defineInstrumentation(
dsn: process.env.E2E_TEST_DSN,
tunnel: 'http://localhost:3031/', // proxy server
tracesSampleRate: 1.0,
+ ...(process.env.SENTRY_GENAI_CONTENT === 'off'
+ ? { dataCollection: { genAI: { inputs: false, outputs: false } } }
+ : {}),
}),
);
diff --git a/dev-packages/e2e-tests/test-applications/node-eve/package.json b/dev-packages/e2e-tests/test-applications/node-eve/package.json
index 978dc8a2dbd8..5b7827bbbc15 100644
--- a/dev-packages/e2e-tests/test-applications/node-eve/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-eve/package.json
@@ -16,7 +16,10 @@
"test:build": "pnpm install && pnpm build",
"test:build-orchestrion": "USE_ORCHESTRION=1 pnpm test:build",
"test:build-latest": "pnpm install && pnpm add eve@latest ai@latest && pnpm build",
+ "test:build-content-off": "SENTRY_GENAI_CONTENT=off pnpm test:build-latest",
"test:assert": "pnpm test:prod && pnpm test:dev",
+ "test:assert-latest": "SENTRY_GENAI_CONTENT=on pnpm test:assert",
+ "test:assert-content-off": "SENTRY_GENAI_CONTENT=off pnpm test:assert",
"test:assert-orchestrion": "USE_ORCHESTRION=1 pnpm test:assert",
"test:prod": "TEST_ENV=production playwright test",
"test:dev": "TEST_ENV=development playwright test"
@@ -32,7 +35,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@types/node": "24.x",
"typescript": "~5.9.0"
},
@@ -44,8 +47,14 @@
"optionalVariants": [
{
"build-command": "pnpm test:build-latest",
+ "assert-command": "pnpm test:assert-latest",
"label": "node-eve (latest)"
},
+ {
+ "build-command": "pnpm test:build-content-off",
+ "assert-command": "pnpm test:assert-content-off",
+ "label": "node-eve (content off, latest)"
+ },
{
"build-command": "pnpm test:build-orchestrion",
"assert-command": "pnpm test:assert-orchestrion",
diff --git a/dev-packages/e2e-tests/test-applications/node-eve/tests/eve.test.ts b/dev-packages/e2e-tests/test-applications/node-eve/tests/eve.test.ts
index 60998bf9ff26..cefa2b6e4adc 100644
--- a/dev-packages/e2e-tests/test-applications/node-eve/tests/eve.test.ts
+++ b/dev-packages/e2e-tests/test-applications/node-eve/tests/eve.test.ts
@@ -3,13 +3,16 @@ import {
GEN_AI_CONVERSATION_ID,
GEN_AI_INPUT_MESSAGES,
GEN_AI_OPERATION_NAME,
+ GEN_AI_OUTPUT_MESSAGES,
GEN_AI_REQUEST_MODEL,
+ GEN_AI_TOOL_CALL_ARGUMENTS,
+ GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_NAME,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_OUTPUT_TOKENS,
SENTRY_ORIGIN,
} from '@sentry/conventions/attributes';
-import { GEN_AI_DECIDE, GEN_AI_EXECUTE_TOOL } from '@sentry/conventions/op';
+import { GEN_AI_DECIDE, GEN_AI_EXECUTE_TOOL, GEN_AI_INVOKE_AGENT } from '@sentry/conventions/op';
import { collectStreamedSpans, getSpanOp, waitForError } from '@sentry-internal/test-utils';
import { runAgentTurn } from './utils';
@@ -67,16 +70,6 @@ test('captures Vercel AI agent spans (invoke_agent, generate_content, execute_to
expect(executeTool?.attributes?.['gen_ai.operation.name']?.value).toBe('execute_tool');
expect(executeTool?.attributes?.['gen_ai.tool.name']?.value).toBe('get_weather');
- // Inputs and outputs are recorded with the SDK's default data collection (no
- // `dataCollection` override), for both the model call and the tool call.
- expect(invokeAgent?.attributes?.['gen_ai.input.messages']?.value).toContain('What is the weather in Paris?');
- expect(typeof invokeAgent?.attributes?.['gen_ai.output.messages']?.value).toBe('string');
- expect(String(invokeAgent?.attributes?.['gen_ai.output.messages']?.value ?? '')).not.toBe('');
-
- expect(executeTool?.attributes?.['gen_ai.tool.call.arguments']?.value).toContain('Paris');
- // The tool returns `{ city, condition: 'Sunny', temperatureC: 22 }`.
- expect(executeTool?.attributes?.['gen_ai.tool.call.result']?.value).toContain('Sunny');
-
// `get_weather` wraps its work in a manual `Sentry.startSpan`. Because eve runs
// the tool while the SDK's `execute_tool` span is active, that user span nests
// directly under it — this is the manual-instrumentation-inside-a-tool case.
@@ -117,6 +110,50 @@ test('captures Vercel AI agent spans (invoke_agent, generate_content, execute_to
}
});
+// `on`: eve >= 1.0.0-rc.10 takes `Sentry.eveInstrumentation()`'s trace policy, so content reaches `ai`'s channel.
+// `off`: Sentry's `dataCollection.genAI` turns content off.
+const genAIContent = process.env.SENTRY_GENAI_CONTENT;
+
+async function runWeatherTurn(baseURL: string) {
+ const traceSpansPromise = collectStreamedSpans(APP, spansOfTrace =>
+ [GEN_AI_INVOKE_AGENT, GEN_AI_EXECUTE_TOOL].every(op => spansOfTrace.some(span => getSpanOp(span) === op)),
+ );
+ await runAgentTurn(baseURL, 'What is the weather in Paris?');
+ const traceSpans = await traceSpansPromise;
+
+ return {
+ invokeAgent: traceSpans.find(span => getSpanOp(span) === GEN_AI_INVOKE_AGENT),
+ executeTool: traceSpans.find(span => getSpanOp(span) === GEN_AI_EXECUTE_TOOL),
+ };
+}
+
+test('records input and output messages and tool data when content is allowed', async ({ baseURL }) => {
+ test.skip(genAIContent !== 'on', 'needs SENTRY_GENAI_CONTENT=on');
+
+ const { invokeAgent, executeTool } = await runWeatherTurn(baseURL!);
+
+ expect(invokeAgent?.attributes?.[GEN_AI_INPUT_MESSAGES]?.value).toContain('What is the weather in Paris?');
+ expect(String(invokeAgent?.attributes?.[GEN_AI_OUTPUT_MESSAGES]?.value ?? '')).not.toBe('');
+ expect(executeTool?.attributes?.[GEN_AI_TOOL_CALL_ARGUMENTS]?.value).toContain('Paris');
+ // The tool returns `{ city, condition: 'Sunny', temperatureC: 22 }`.
+ expect(executeTool?.attributes?.[GEN_AI_TOOL_CALL_RESULT]?.value).toContain('Sunny');
+});
+
+test('records usage but no messages when content is not allowed', async ({ baseURL }) => {
+ // eve allows content in development, so without Sentry's opt-out only production shows the default.
+ test.skip(
+ genAIContent === 'on' || (genAIContent !== 'off' && process.env.TEST_ENV !== 'production'),
+ 'only without content',
+ );
+
+ const { invokeAgent } = await runWeatherTurn(baseURL!);
+
+ // `ai` >= 7.0.163 strips inputs and withholds results for calls with `recordInputs`/`recordOutputs: false`.
+ expect(invokeAgent?.attributes?.[GEN_AI_INPUT_MESSAGES]).toBeUndefined();
+ expect(invokeAgent?.attributes?.[GEN_AI_OUTPUT_MESSAGES]).toBeUndefined();
+ expect(typeof invokeAgent?.attributes?.[GEN_AI_USAGE_INPUT_TOKENS]?.value).toBe('number');
+});
+
test('captures errors thrown inside an eve tool', async ({ baseURL }) => {
const errorPromise = waitForError(
APP,
@@ -147,6 +184,9 @@ test('captures errors thrown inside an eve tool', async ({ baseURL }) => {
});
test('captures a gen_ai.decide span for a Jev call inside an eve tool', async ({ baseURL }) => {
+ // `ai` keeps no usage or input on decide spans for calls with recording off.
+ test.skip(genAIContent === 'off', 'needs gen_ai content');
+
const traceSpansPromise = collectStreamedSpans(APP, spansOfTrace =>
[GEN_AI_EXECUTE_TOOL, GEN_AI_DECIDE].every(op => spansOfTrace.some(span => getSpanOp(span) === op)),
);
diff --git a/dev-packages/e2e-tests/test-applications/node-express-otlp/otel-v2/tracer-provider.ts b/dev-packages/e2e-tests/test-applications/node-express-otlp/otel-v2/tracer-provider.ts
new file mode 100644
index 000000000000..d87aab506191
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/node-express-otlp/otel-v2/tracer-provider.ts
@@ -0,0 +1,9 @@
+import type { SpanExporter } from '@opentelemetry/sdk-trace-base';
+import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
+import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
+
+export function registerTracerProvider(exporter: SpanExporter): void {
+ new NodeTracerProvider({
+ spanProcessors: [new BatchSpanProcessor(exporter, { scheduledDelayMillis: 100 })],
+ }).register();
+}
diff --git a/dev-packages/e2e-tests/test-applications/node-express-otlp/package.json b/dev-packages/e2e-tests/test-applications/node-express-otlp/package.json
index 70d0b7343d22..ac311b7023b1 100644
--- a/dev-packages/e2e-tests/test-applications/node-express-otlp/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-express-otlp/package.json
@@ -8,13 +8,15 @@
"test": "playwright test",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
+ "test:build:otel-v2": "pnpm remove @opentelemetry/context-async-hooks @opentelemetry/core @opentelemetry/sdk-trace && pnpm add @opentelemetry/api@1.9.1 @opentelemetry/exporter-trace-otlp-http@^0.220.0 @opentelemetry/sdk-trace-base@^2.9.0 @opentelemetry/sdk-trace-node@^2.9.0 && pnpm dedupe && cp otel-v2/tracer-provider.ts src/tracer-provider.ts && pnpm build",
"test:assert": "pnpm test"
},
"dependencies": {
- "@opentelemetry/api": "^1.9.1",
- "@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
- "@opentelemetry/sdk-trace-base": "^2.9.0",
- "@opentelemetry/sdk-trace-node": "^2.9.0",
+ "@opentelemetry/api": "^1.10.0",
+ "@opentelemetry/context-async-hooks": "^3.0.0",
+ "@opentelemetry/core": "^3.0.0",
+ "@opentelemetry/exporter-trace-otlp-http": "^0.300.0",
+ "@opentelemetry/sdk-trace": "^3.0.0",
"@sentry/node": "file:../../packed/sentry-node-packed.tgz",
"@types/express": "^4.17.21",
"@types/node": "^18.19.1",
@@ -24,5 +26,14 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
+ },
+ "sentryTest": {
+ "variants": [
+ {
+ "build-command": "pnpm test:build:otel-v2",
+ "assert-command": "pnpm test:assert",
+ "label": "node-express-otlp (OTel SDK v2)"
+ }
+ ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/node-express-otlp/src/app.ts b/dev-packages/e2e-tests/test-applications/node-express-otlp/src/app.ts
index c6246a18f3a9..e6cb40ad2639 100644
--- a/dev-packages/e2e-tests/test-applications/node-express-otlp/src/app.ts
+++ b/dev-packages/e2e-tests/test-applications/node-express-otlp/src/app.ts
@@ -1,9 +1,8 @@
import { trace } from '@opentelemetry/api';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
-import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
-import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import * as Sentry from '@sentry/node';
import express from 'express';
+import { registerTracerProvider } from './tracer-provider';
const dsn = process.env.E2E_TEST_DSN as string;
const appPort = 3030;
@@ -17,19 +16,12 @@ if (!otlpTracesEndpoint) {
// The user brings their own OpenTelemetry setup. In production `url` would be
// `otlpTracesEndpoint.url`; here it points at the local receiver below so the test can assert what
// was actually exported. The auth headers are the real DSN-derived ones either way.
-const provider = new NodeTracerProvider({
- spanProcessors: [
- new BatchSpanProcessor(
- new OTLPTraceExporter({
- url: `http://localhost:${otlpReceiverPort}/v1/traces`,
- headers: otlpTracesEndpoint.headers,
- }),
- { scheduledDelayMillis: 100 },
- ),
- ],
-});
-
-provider.register();
+registerTracerProvider(
+ new OTLPTraceExporter({
+ url: `http://localhost:${otlpReceiverPort}/v1/traces`,
+ headers: otlpTracesEndpoint.headers,
+ }),
+);
Sentry.init({
dsn,
diff --git a/dev-packages/e2e-tests/test-applications/node-express-otlp/src/tracer-provider.ts b/dev-packages/e2e-tests/test-applications/node-express-otlp/src/tracer-provider.ts
new file mode 100644
index 000000000000..ec591e7e4c14
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/node-express-otlp/src/tracer-provider.ts
@@ -0,0 +1,20 @@
+import { context, propagation, trace } from '@opentelemetry/api';
+import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
+import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
+import type { SpanExporter } from '@opentelemetry/sdk-trace';
+import { BatchSpanProcessor, TracerProvider } from '@opentelemetry/sdk-trace';
+
+// OpenTelemetry SDK v3 has no `NodeTracerProvider.register()`, so the app registers the tracer
+// provider, context manager and propagator itself. The OTel SDK v2 variant replaces this file with
+// `otel-v2/tracer-provider.ts`.
+export function registerTracerProvider(exporter: SpanExporter): void {
+ trace.setGlobalTracerProvider(
+ new TracerProvider({
+ spanProcessors: [new BatchSpanProcessor({ exporter, scheduledDelayMillis: 100 })],
+ }),
+ );
+ context.setGlobalContextManager(new AsyncLocalStorageContextManager().enable());
+ propagation.setGlobalPropagator(
+ new CompositePropagator({ propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()] }),
+ );
+}
diff --git a/dev-packages/e2e-tests/test-applications/node-express-static/package.json b/dev-packages/e2e-tests/test-applications/node-express-static/package.json
index 4e05d8429c08..71339a610d87 100644
--- a/dev-packages/e2e-tests/test-applications/node-express-static/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-express-static/package.json
@@ -25,14 +25,5 @@
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"@sentry/core": "file:../../packed/sentry-core-packed.tgz"
- },
- "sentryTest": {
- "variants": [
- {
- "build-command": "E2E_TEST_OTEL_SETUP=true pnpm test:build",
- "assert-command": "E2E_TEST_OTEL_SETUP=true pnpm test:assert",
- "label": "node-express (tracer provider)"
- }
- ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/node-express-static/src/app.ts b/dev-packages/e2e-tests/test-applications/node-express-static/src/app.ts
index 4fe40c8da5df..dd5ace65f9a2 100644
--- a/dev-packages/e2e-tests/test-applications/node-express-static/src/app.ts
+++ b/dev-packages/e2e-tests/test-applications/node-express-static/src/app.ts
@@ -24,9 +24,6 @@ Sentry.init({
outputs: false,
},
},
- // Opt into the Sentry OpenTelemetry tracer provider in the "(tracer provider)" e2e variant.
- // Leaving it `undefined` otherwise keeps the SDK's default (no provider).
- enableOpenTelemetrySetup: process.env.E2E_TEST_OTEL_SETUP === 'true' ? true : undefined,
integrations: [
Sentry.nativeNodeFetchIntegration({
headersToSpanAttributes: {
diff --git a/dev-packages/e2e-tests/test-applications/node-express/package.json b/dev-packages/e2e-tests/test-applications/node-express/package.json
index adc4b406f5d4..281f5211a5ea 100644
--- a/dev-packages/e2e-tests/test-applications/node-express/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-express/package.json
@@ -12,6 +12,7 @@
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.26.0",
+ "@opentelemetry/api": "^1.9.1",
"@sentry/node": "file:../../packed/sentry-node-packed.tgz",
"@trpc/server": "10.45.4",
"@trpc/client": "10.45.4",
@@ -24,6 +25,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
+ "@sentry/conventions": "0.33.0",
"@sentry/core": "file:../../packed/sentry-core-packed.tgz"
},
"sentryTest": {
diff --git a/dev-packages/e2e-tests/test-applications/node-express/src/app.ts b/dev-packages/e2e-tests/test-applications/node-express/src/app.ts
index 1f196b138dd8..b202ee049ee1 100644
--- a/dev-packages/e2e-tests/test-applications/node-express/src/app.ts
+++ b/dev-packages/e2e-tests/test-applications/node-express/src/app.ts
@@ -33,6 +33,7 @@ Sentry.init({
],
});
+import { trace } from '@opentelemetry/api';
import { TRPCError, initTRPC } from '@trpc/server';
import * as trpcExpress from '@trpc/server/adapters/express';
import express from 'express';
@@ -77,6 +78,16 @@ app.get('/test-transaction', function (_req, res) {
res.send({ status: 'ok' });
});
+app.get('/test-otel-api-span', function (_req, res) {
+ const tracer = trace.getTracer('node-express');
+ tracer.startActiveSpan('otel-api-span', span => {
+ tracer.startActiveSpan('otel-api-child-span', childSpan => childSpan.end());
+ span.end();
+ });
+
+ res.send({ status: 'ok' });
+});
+
app.get('/test-outgoing-fetch', async function (_req, res) {
const response = await fetch('http://localhost:3030/test-success');
const data = await response.json();
diff --git a/dev-packages/e2e-tests/test-applications/node-express/tests/otel-api.test.ts b/dev-packages/e2e-tests/test-applications/node-express/tests/otel-api.test.ts
new file mode 100644
index 000000000000..fe2b3ed82150
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/node-express/tests/otel-api.test.ts
@@ -0,0 +1,36 @@
+import { expect, test } from '@playwright/test';
+import { collectStreamedSpansUntilSegment, getSpanOp } from '@sentry-internal/test-utils';
+import { HTTP_SERVER } from '@sentry/conventions/op';
+
+test.skip(process.env.E2E_TEST_OTEL_SETUP !== 'true', 'Only runs in the tracer provider variant');
+
+test('Captures spans started via @opentelemetry/api as children of the request span', async ({ baseURL }) => {
+ const spansPromise = collectStreamedSpansUntilSegment(
+ 'node-express',
+ segment => getSpanOp(segment) === HTTP_SERVER && segment.name === 'GET /test-otel-api-span',
+ );
+
+ await fetch(`${baseURL}/test-otel-api-span`);
+
+ const spans = await spansPromise;
+ const segmentSpan = spans.find(span => span.is_segment && span.name === 'GET /test-otel-api-span')!;
+ const otelSpan = spans.find(span => span.name === 'otel-api-span');
+ const otelChildSpan = spans.find(span => span.name === 'otel-api-child-span');
+
+ expect(otelSpan).toEqual(
+ expect.objectContaining({
+ trace_id: segmentSpan.trace_id,
+ is_segment: false,
+ attributes: expect.objectContaining({
+ 'sentry.segment.id': { value: segmentSpan.span_id, type: 'string' },
+ }),
+ }),
+ );
+ expect(otelChildSpan).toEqual(
+ expect.objectContaining({
+ trace_id: segmentSpan.trace_id,
+ parent_span_id: otelSpan!.span_id,
+ is_segment: false,
+ }),
+ );
+});
diff --git a/dev-packages/e2e-tests/test-applications/node-fastify-5/package.json b/dev-packages/e2e-tests/test-applications/node-fastify-5/package.json
index fc96a360b6ec..205729484a3d 100644
--- a/dev-packages/e2e-tests/test-applications/node-fastify-5/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-fastify-5/package.json
@@ -20,14 +20,5 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
- },
- "sentryTest": {
- "variants": [
- {
- "build-command": "E2E_TEST_OTEL_SETUP=true pnpm test:build",
- "assert-command": "E2E_TEST_OTEL_SETUP=true pnpm test:assert",
- "label": "node-fastify-5 (tracer provider)"
- }
- ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/node-fastify-5/src/app.ts b/dev-packages/e2e-tests/test-applications/node-fastify-5/src/app.ts
index 93c942bd16ef..d17c8cf6abb9 100644
--- a/dev-packages/e2e-tests/test-applications/node-fastify-5/src/app.ts
+++ b/dev-packages/e2e-tests/test-applications/node-fastify-5/src/app.ts
@@ -36,9 +36,6 @@ Sentry.init({
tracesSampleRate: 1,
tunnel: 'http://localhost:3031/', // proxy server
tracePropagationTargets: ['http://localhost:3030', '/external-allowed'],
- // Opt into the Sentry OpenTelemetry tracer provider in the "(tracer provider)" e2e variant.
- // Leaving it `undefined` otherwise keeps the SDK's default (no provider).
- enableOpenTelemetrySetup: process.env.E2E_TEST_OTEL_SETUP === 'true' ? true : undefined,
});
import type * as H from 'http';
diff --git a/dev-packages/e2e-tests/test-applications/node-fastify-6/package.json b/dev-packages/e2e-tests/test-applications/node-fastify-6/package.json
index fc948455cba7..ce07fd7af7e3 100644
--- a/dev-packages/e2e-tests/test-applications/node-fastify-6/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-fastify-6/package.json
@@ -22,13 +22,6 @@
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
},
"sentryTest": {
- "optional": true,
- "optionalVariants": [
- {
- "build-command": "E2E_TEST_OTEL_SETUP=true pnpm test:build",
- "assert-command": "E2E_TEST_OTEL_SETUP=true pnpm test:assert",
- "label": "node-fastify-6 (tracer provider)"
- }
- ]
+ "optional": true
}
}
diff --git a/dev-packages/e2e-tests/test-applications/node-fastify-6/src/app.ts b/dev-packages/e2e-tests/test-applications/node-fastify-6/src/app.ts
index d2135c2e8c69..2892ef342e9c 100644
--- a/dev-packages/e2e-tests/test-applications/node-fastify-6/src/app.ts
+++ b/dev-packages/e2e-tests/test-applications/node-fastify-6/src/app.ts
@@ -35,8 +35,6 @@ Sentry.init({
tracesSampleRate: 1,
tunnel: 'http://localhost:3031/', // proxy server
tracePropagationTargets: ['http://localhost:3030', '/external-allowed'],
- // Only the "(tracer provider)" variant opts in; `undefined` keeps the SDK default
- enableOpenTelemetrySetup: process.env.E2E_TEST_OTEL_SETUP === 'true' ? true : undefined,
});
import type * as H from 'http';
diff --git a/dev-packages/e2e-tests/test-applications/node-flue/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/node-flue/pnpm-workspace.yaml
index 0e523a16e6f0..dc147be05267 100644
--- a/dev-packages/e2e-tests/test-applications/node-flue/pnpm-workspace.yaml
+++ b/dev-packages/e2e-tests/test-applications/node-flue/pnpm-workspace.yaml
@@ -4,3 +4,8 @@ allowBuilds:
esbuild: true
protobufjs: false
minimumReleaseAge: 0
+# @flue/runtime 2.3.0 imports `Type` from pi-ai, which pi 1.5.0 stopped re-exporting
+# (https://github.com/withastro/flue/issues/912). Scoped to ^1 so the pinned variant (pi 0.83) is untouched.
+overrides:
+ '@earendil-works/pi-ai@^1': '1.4.0'
+ '@earendil-works/pi-agent-core@^1': '1.4.0'
diff --git a/dev-packages/e2e-tests/test-applications/node-flue/tests/flue.test.ts b/dev-packages/e2e-tests/test-applications/node-flue/tests/flue.test.ts
index a829a0ba282e..49c3197032d0 100644
--- a/dev-packages/e2e-tests/test-applications/node-flue/tests/flue.test.ts
+++ b/dev-packages/e2e-tests/test-applications/node-flue/tests/flue.test.ts
@@ -33,11 +33,11 @@ test('captures the invoke_agent / chat / execute_tool hierarchy for a Flue turn'
expect(invokeAgent?.attributes?.['gen_ai.operation.name']?.value).toBe('invoke_agent');
expect(invokeAgent?.attributes?.['gen_ai.agent.name']?.value).toBe('Hello');
- expect(chat?.attributes?.['sentry.origin']?.value).toBe('auto.ai.flue');
+ expect(chat?.attributes?.['sentry.origin']?.value).toBe('auto.ai.pi_ai');
expect(chat?.attributes?.['gen_ai.provider.name']?.value).toBe('openrouter');
expect(typeof chat?.attributes?.['gen_ai.usage.input_tokens']?.value).toBe('number');
expect(typeof chat?.attributes?.['gen_ai.usage.output_tokens']?.value).toBe('number');
- // Flue computes cost itself; no provider SDK reports it.
+ // pi-ai computes cost itself; no provider SDK reports it.
expect(typeof chat?.attributes?.['gen_ai.cost.total_tokens']?.value).toBe('number');
expect(executeTool?.attributes?.['gen_ai.tool.name']?.value).toBe('get_weather');
@@ -92,7 +92,7 @@ test('nests a manual span raised inside a tool under that tool span', async ({ b
expect(manualSpan?.parent_span_id).toBe(executeTool?.span_id);
});
-// Flue's `model` operation is wrapped so the turn span is active for it, which is what puts the
+// The pi-ai integration makes the chat span active for the request it sends, which is what puts the
// provider's HTTP call inside `chat` rather than beside it.
test('nests the provider HTTP call inside the chat span', async ({ baseURL }) => {
const spansPromise = collectStreamedSpans(
diff --git a/dev-packages/e2e-tests/test-applications/node-hapi/package.json b/dev-packages/e2e-tests/test-applications/node-hapi/package.json
index 70e17ef2e6f1..8026ca581200 100644
--- a/dev-packages/e2e-tests/test-applications/node-hapi/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-hapi/package.json
@@ -17,7 +17,7 @@
},
"devDependencies": {
"@playwright/test": "1.64.1",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
}
}
diff --git a/dev-packages/e2e-tests/test-applications/node-mastra/package.json b/dev-packages/e2e-tests/test-applications/node-mastra/package.json
index d2cf7f675fc3..a2627e5d681a 100644
--- a/dev-packages/e2e-tests/test-applications/node-mastra/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-mastra/package.json
@@ -29,7 +29,7 @@
"@mastra/deployer": "~1.74.0",
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@types/node": "24.x",
"mastra": "~1.28.0",
"typescript": "~5.9.0"
diff --git a/dev-packages/e2e-tests/test-applications/node-openai-decisions/package.json b/dev-packages/e2e-tests/test-applications/node-openai-decisions/package.json
index 94125ec7a332..12793f352adc 100644
--- a/dev-packages/e2e-tests/test-applications/node-openai-decisions/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-openai-decisions/package.json
@@ -24,7 +24,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@types/express": "^4.17.21",
"@types/node": "^24.0.0",
"typescript": "~5.9.0"
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/package.json b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/package.json
deleted file mode 100644
index 906c97985e07..000000000000
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/package.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "name": "node-otel-sdk-node-v3",
- "version": "1.0.0",
- "private": true,
- "scripts": {
- "start": "node --import ./src/instrument.mjs src/app.mjs",
- "clean": "npx rimraf node_modules pnpm-lock.yaml",
- "test:build": "pnpm install",
- "test:assert": "playwright test"
- },
- "dependencies": {
- "@opentelemetry/api": "^1.10.0",
- "@opentelemetry/exporter-trace-otlp-http": "^0.300.0",
- "@opentelemetry/instrumentation": "^0.300.0",
- "@opentelemetry/instrumentation-http": "^0.300.0",
- "@opentelemetry/sdk-node": "^0.300.0",
- "@opentelemetry/sdk-trace": "^3.0.0",
- "@sentry/node": "file:../../packed/sentry-node-packed.tgz",
- "express": "^4.21.2"
- },
- "devDependencies": {
- "@playwright/test": "1.64.1",
- "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
- }
-}
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/playwright.config.mjs
deleted file mode 100644
index 888e61cfb2dc..000000000000
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/playwright.config.mjs
+++ /dev/null
@@ -1,34 +0,0 @@
-import { getPlaywrightConfig } from '@sentry-internal/test-utils';
-
-const config = getPlaywrightConfig(
- {
- startCommand: `pnpm start`,
- },
- {
- webServer: [
- {
- command: `node ./start-event-proxy.mjs`,
- port: 3031,
- stdout: 'pipe',
- stderr: 'pipe',
- },
- {
- command: `node ./start-otel-proxy.mjs`,
- port: 3032,
- stdout: 'pipe',
- stderr: 'pipe',
- },
- {
- command: 'pnpm start',
- port: 3030,
- stdout: 'pipe',
- stderr: 'pipe',
- env: {
- PORT: 3030,
- },
- },
- ],
- },
-);
-
-export default config;
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/src/app.mjs b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/src/app.mjs
deleted file mode 100644
index ee441975d47c..000000000000
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/src/app.mjs
+++ /dev/null
@@ -1,47 +0,0 @@
-import { trace } from '@opentelemetry/api';
-import * as Sentry from '@sentry/node';
-import express from 'express';
-import http from 'node:http';
-
-const app = express();
-const port = 3030;
-const tracer = trace.getTracer('node-otel-sdk-node-v3');
-
-app.get('/test-telemetry/:id', function (req, res) {
- tracer.startActiveSpan('telemetry-handler', span => {
- const { traceId, spanId } = span.spanContext();
-
- Sentry.captureException(new Error(`This is an exception with id ${req.params.id}`));
-
- span.end();
-
- res.json({ traceId, spanId });
- });
-});
-
-app.get('/test-exception/:id', function (req, _res) {
- throw new Error(`This is an exception with id ${req.params.id}`);
-});
-
-app.get('/test-outgoing', function (_req, res) {
- http.get(`http://localhost:${port}/echo-headers`, response => {
- let body = '';
- response.on('data', chunk => (body += chunk));
- response.on('end', () => res.type('json').send(body));
- });
-});
-
-app.get('/echo-headers', function (req, res) {
- res.send(req.headers);
-});
-
-// Answers with the OpenTelemetry span the request ran under, so the test can check what the error
-// captured by Sentry was linked to.
-app.use(function onError(_err, _req, res, _next) {
- const spanContext = trace.getActiveSpan()?.spanContext();
- res.status(500).json({ traceId: spanContext?.traceId, spanId: spanContext?.spanId });
-});
-
-app.listen(port, () => {
- console.log(`Example app listening on port ${port}`);
-});
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/start-otel-proxy.mjs b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/start-otel-proxy.mjs
deleted file mode 100644
index 0a3a31f582b2..000000000000
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/start-otel-proxy.mjs
+++ /dev/null
@@ -1,6 +0,0 @@
-import { startProxyServer } from '@sentry-internal/test-utils';
-
-startProxyServer({
- port: 3032,
- proxyServerName: 'node-otel-sdk-node-v3-otel',
-});
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/tests/errors.test.ts
deleted file mode 100644
index 603e9c053aaa..000000000000
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/tests/errors.test.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { waitForError } from '@sentry-internal/test-utils';
-
-test('links errors to the active OpenTelemetry span', async ({ baseURL }) => {
- const errorEventPromise = waitForError('node-otel-sdk-node-v3', errorEvent => {
- return errorEvent.exception?.values?.[0]?.value === 'This is an exception with id 123';
- });
-
- const response = await fetch(`${baseURL}/test-telemetry/123`);
- const { traceId, spanId } = (await response.json()) as { traceId: string; spanId: string };
-
- const errorEvent = await errorEventPromise;
-
- expect(errorEvent.contexts?.trace).toEqual({ trace_id: traceId, span_id: spanId });
-});
-
-test('links errors from the Sentry instrumentation to the active OpenTelemetry span', async ({ baseURL }) => {
- const errorEventPromise = waitForError('node-otel-sdk-node-v3', errorEvent => {
- return errorEvent.exception?.values?.[0]?.value === 'This is an exception with id 456';
- });
-
- const response = await fetch(`${baseURL}/test-exception/456`);
- const { traceId, spanId } = (await response.json()) as { traceId: string; spanId: string };
-
- const errorEvent = await errorEventPromise;
-
- // With tracing off, Sentry's channel instrumentation still runs and reports the errors express
- // never handles.
- expect(errorEvent.exception?.values?.[0]?.mechanism).toEqual({ type: 'auto.http.express', handled: false });
- expect(errorEvent.contexts?.trace).toEqual({ trace_id: traceId, span_id: spanId });
-});
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/tests/opentelemetry.test.ts b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/tests/opentelemetry.test.ts
deleted file mode 100644
index cbeffac8b286..000000000000
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/tests/opentelemetry.test.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { waitForError, waitForPlainRequest, waitForTransaction } from '@sentry-internal/test-utils';
-
-interface OtlpSpan {
- name: string;
- traceId: string;
-}
-
-/**
- * The proxy hands back the payloads it received as newline separated JSON, so a single read can
- * hold more than one OTLP export.
- */
-function getExportedSpans(data: string): OtlpSpan[] {
- return data
- .split('\n')
- .filter(Boolean)
- .flatMap(
- line => (JSON.parse(line) as { resourceSpans?: { scopeSpans?: { spans?: OtlpSpan[] }[] }[] }).resourceSpans ?? [],
- )
- .flatMap(resourceSpan => resourceSpan.scopeSpans ?? [])
- .flatMap(scopeSpan => scopeSpan.spans ?? []);
-}
-
-test('exports the spans of the user OpenTelemetry setup to their own collector', async ({ baseURL }) => {
- let traceId: string | undefined;
-
- // Every test in this app exports into the same proxy, and the http span only ends once the
- // response is out, so wait for this request's own trace to be complete. Waiting on the span names
- // alone matches a batch that another test filled, whose spans are on a different trace.
- const otelExportPromise = waitForPlainRequest('node-otel-sdk-node-v3-otel', data => {
- const names = getExportedSpans(data)
- .filter(span => span.traceId === traceId)
- .map(span => span.name);
- return names.includes('telemetry-handler') && names.includes('GET');
- });
-
- const response = await fetch(`${baseURL}/test-telemetry/234`);
- ({ traceId } = (await response.json()) as { traceId: string });
-
- const exportedSpans = getExportedSpans(await otelExportPromise).filter(span => span.traceId === traceId);
-
- // The user's own http instrumentation keeps working and stays on the same trace as their spans.
- expect(exportedSpans.map(span => span.name)).toEqual(expect.arrayContaining(['telemetry-handler', 'GET']));
-});
-
-test('sends no spans to Sentry', async ({ baseURL }) => {
- const transactionPromise = waitForTransaction('node-otel-sdk-node-v3', () => true);
- const errorPromise = waitForError('node-otel-sdk-node-v3', errorEvent => {
- return errorEvent.exception?.values?.[0]?.value === 'This is an exception with id 345';
- });
-
- await fetch(`${baseURL}/test-telemetry/345`);
- // Proves the request's telemetry reached the proxy, so the absence check below is not vacuous.
- await errorPromise;
-
- // Absence can only be time bounded. This guards against Sentry's own instrumentation emitting
- // spans again, which would produce a transaction for every request, well inside this window.
- const transaction = await Promise.race([
- transactionPromise,
- new Promise(resolve => setTimeout(() => resolve(undefined), 3000)),
- ]);
-
- expect(transaction).toBeUndefined();
-});
-
-test('leaves outgoing trace propagation to the user propagator', async ({ baseURL }) => {
- const response = await fetch(`${baseURL}/test-outgoing`);
- const headers = (await response.json()) as Record;
-
- expect(headers['traceparent']).toMatch(/^00-[a-f0-9]{32}-[a-f0-9]{16}-\d{2}$/);
- expect(headers['sentry-trace']).toBeUndefined();
- expect(headers['baggage']).toBeUndefined();
-});
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/package.json b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/package.json
index 809cb1a510fc..c9a16056ae37 100644
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/package.json
@@ -3,23 +3,34 @@
"version": "1.0.0",
"private": true,
"scripts": {
- "start": "node --import ./src/instrument.mjs src/app.mjs",
+ "start": "node --import ./src/${INSTRUMENT_FILE:-instrument.mjs} src/app.mjs",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install",
- "test:assert": "playwright test"
+ "test:build:otel-v2": "pnpm remove @opentelemetry/sdk-trace && pnpm add @opentelemetry/api@1.9.1 @opentelemetry/exporter-trace-otlp-http@^0.220.0 @opentelemetry/instrumentation@^0.220.0 @opentelemetry/instrumentation-http@^0.220.0 @opentelemetry/sdk-node@^0.220.0 @opentelemetry/sdk-trace-base@^2.9.0 && pnpm dedupe",
+ "test:assert": "playwright test",
+ "test:assert:otel-v2": "INSTRUMENT_FILE=instrument-otel-v2.mjs playwright test"
},
"dependencies": {
- "@opentelemetry/api": "1.9.1",
- "@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
- "@opentelemetry/instrumentation": "^0.220.0",
- "@opentelemetry/instrumentation-http": "^0.220.0",
- "@opentelemetry/sdk-node": "^0.220.0",
- "@opentelemetry/sdk-trace-base": "^2.9.0",
+ "@opentelemetry/api": "^1.10.0",
+ "@opentelemetry/exporter-trace-otlp-http": "^0.300.0",
+ "@opentelemetry/instrumentation": "^0.300.0",
+ "@opentelemetry/instrumentation-http": "^0.300.0",
+ "@opentelemetry/sdk-node": "^0.300.0",
+ "@opentelemetry/sdk-trace": "^3.0.0",
"@sentry/node": "file:../../packed/sentry-node-packed.tgz",
"express": "^4.21.2"
},
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
+ },
+ "sentryTest": {
+ "variants": [
+ {
+ "build-command": "pnpm test:build:otel-v2",
+ "assert-command": "pnpm test:assert:otel-v2",
+ "label": "node-otel-sdk-node (OTel SDK v2)"
+ }
+ ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/src/instrument.mjs b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/src/instrument-otel-v2.mjs
similarity index 86%
rename from dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/src/instrument.mjs
rename to dev-packages/e2e-tests/test-applications/node-otel-sdk-node/src/instrument-otel-v2.mjs
index c9b910fd3122..25749a79ff21 100644
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/src/instrument.mjs
+++ b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/src/instrument-otel-v2.mjs
@@ -1,7 +1,7 @@
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { NodeSDK } from '@opentelemetry/sdk-node';
-import { BatchSpanProcessor } from '@opentelemetry/sdk-trace';
+import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import * as Sentry from '@sentry/node';
import { register } from 'node:module';
@@ -16,10 +16,7 @@ register('@opentelemetry/instrumentation/hook.mjs', import.meta.url);
const sdk = new NodeSDK({
instrumentations: [new HttpInstrumentation()],
spanProcessors: [
- new BatchSpanProcessor({
- exporter: new OTLPTraceExporter({ url: 'http://localhost:3032/' }),
- scheduledDelayMillis: 100,
- }),
+ new BatchSpanProcessor(new OTLPTraceExporter({ url: 'http://localhost:3032/' }), { scheduledDelayMillis: 100 }),
],
});
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/src/instrument.mjs b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/src/instrument.mjs
index 25749a79ff21..c9b910fd3122 100644
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/src/instrument.mjs
+++ b/dev-packages/e2e-tests/test-applications/node-otel-sdk-node/src/instrument.mjs
@@ -1,7 +1,7 @@
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { NodeSDK } from '@opentelemetry/sdk-node';
-import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
+import { BatchSpanProcessor } from '@opentelemetry/sdk-trace';
import * as Sentry from '@sentry/node';
import { register } from 'node:module';
@@ -16,7 +16,10 @@ register('@opentelemetry/instrumentation/hook.mjs', import.meta.url);
const sdk = new NodeSDK({
instrumentations: [new HttpInstrumentation()],
spanProcessors: [
- new BatchSpanProcessor(new OTLPTraceExporter({ url: 'http://localhost:3032/' }), { scheduledDelayMillis: 100 }),
+ new BatchSpanProcessor({
+ exporter: new OTLPTraceExporter({ url: 'http://localhost:3032/' }),
+ scheduledDelayMillis: 100,
+ }),
],
});
diff --git a/dev-packages/e2e-tests/test-applications/node-pi-durable/package.json b/dev-packages/e2e-tests/test-applications/node-pi-durable/package.json
index 2f2fdcc528ae..0462d710b941 100644
--- a/dev-packages/e2e-tests/test-applications/node-pi-durable/package.json
+++ b/dev-packages/e2e-tests/test-applications/node-pi-durable/package.json
@@ -20,7 +20,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@types/node": "24.x"
},
"engines": {
diff --git a/dev-packages/e2e-tests/test-applications/node-pi-durable/tests/pi-durable.test.ts b/dev-packages/e2e-tests/test-applications/node-pi-durable/tests/pi-durable.test.ts
index 3c18f1bc8cc3..42de516c91bc 100644
--- a/dev-packages/e2e-tests/test-applications/node-pi-durable/tests/pi-durable.test.ts
+++ b/dev-packages/e2e-tests/test-applications/node-pi-durable/tests/pi-durable.test.ts
@@ -52,14 +52,16 @@ test('traces a run as invoke_agent with chat, execute_tool and provider spans',
// pi-ai sends the requests through `@anthropic-ai/sdk`, whose own integration must stay out so
// each request is reported once.
expect(spans.filter(span => String(span.attributes[SENTRY_ORIGIN]?.value).startsWith('auto.ai.'))).toEqual(
- spans.filter(span => span.attributes[SENTRY_ORIGIN]?.value === 'auto.ai.pi_durable'),
+ spans.filter(span =>
+ ['auto.ai.pi_durable', 'auto.ai.pi_ai'].includes(String(span.attributes[SENTRY_ORIGIN]?.value)),
+ ),
);
// One tool-calling response, then the answer.
expect(chats.length).toBeGreaterThanOrEqual(2);
for (const chat of chats) {
expect(chat.parent_span_id).toBe(agent.span_id);
- expect(chat.attributes[SENTRY_ORIGIN]?.value).toBe('auto.ai.pi_durable');
+ expect(chat.attributes[SENTRY_ORIGIN]?.value).toBe('auto.ai.pi_ai');
expect(chat.attributes[GEN_AI_PROVIDER_NAME]?.value).toBe('openrouter');
expect(chat.attributes[GEN_AI_REQUEST_MODEL]?.value).toBe('anthropic/claude-haiku-4.5');
// pi-durable retries a provider error inside the run; such a request has no usage and no HTTP span
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/nuxt.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/nuxt.config.ts
index b83483ac0363..63f6e2e2633b 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/nuxt.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/nuxt.config.ts
@@ -2,8 +2,6 @@
export default defineNuxtConfig({
compatibilityDate: '2025-06-06',
modules: ['@sentry/nuxt/module'],
- // The tunnel variant serves the app, and so the tunnel, under a base URL.
- ...(process.env.E2E_TEST_TUNNEL && { app: { baseURL: '/app/' } }),
nitro: {
preset: 'cloudflare_module',
cloudflare: {
@@ -16,9 +14,5 @@ export default defineNuxtConfig({
alias: {
'readable-stream': 'node:stream',
},
- // The tunnel variant serves the managed tunnel.
- replace: {
- __E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
- },
},
});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/package.json b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/package.json
index 7fb1258723d6..468f0fc85416 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/package.json
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/package.json
@@ -8,9 +8,7 @@
"preview": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --port 3030 --log-level=$(test $CI && echo 'none' || echo 'log')",
"test": "playwright test",
"test:build": "pnpm install && pnpm build",
- "test:assert": "pnpm test",
- "test:build:tunnel": "pnpm install && E2E_TEST_TUNNEL=1 pnpm build",
- "test:assert:tunnel": "E2E_TEST_TUNNEL=1 pnpm test tunnel"
+ "test:assert": "pnpm test"
},
"dependencies": {
"@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz",
@@ -22,14 +20,5 @@
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"wrangler": "^4.72.0"
- },
- "sentryTest": {
- "variants": [
- {
- "build-command": "pnpm test:build:tunnel",
- "assert-command": "pnpm test:assert:tunnel",
- "label": "nuxt-4-cloudflare (tunnel)"
- }
- ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/api/anchor.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/api/anchor.ts
deleted file mode 100644
index cee7601e363b..000000000000
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/api/anchor.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { defineEventHandler } from '#imports';
-
-// A plain route for tests to request after the tunnel traffic.
-export default defineEventHandler(() => 'ok');
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/api/post-error.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/api/post-error.ts
deleted file mode 100644
index 42a0d62de815..000000000000
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/api/post-error.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { defineEventHandler } from '#imports';
-
-// Throws, so a test can check what request data the error event carries.
-export default defineEventHandler(() => {
- throw new Error('POST error');
-});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/plugins/sentry.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/plugins/sentry.ts
index e4cc28eaf3ae..faa56e1db7ef 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/plugins/sentry.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/plugins/sentry.ts
@@ -1,15 +1,10 @@
import { defineNitroPlugin } from '#imports';
-import { serveTunnelIntegration } from '@sentry/cloudflare';
import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins';
-declare const __E2E_TEST_TUNNEL__: boolean;
-
export default defineNitroPlugin(
sentryCloudflareNitroPlugin({
- // The tunnel forwards to the DSN host, which is the event proxy in the tunnel variant.
- dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
- integrations: __E2E_TEST_TUNNEL__ ? [serveTunnelIntegration()] : [],
}),
);
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tests/tunnel-request-body.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tests/tunnel-request-body.test.ts
deleted file mode 100644
index aaca20e2a3eb..000000000000
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tests/tunnel-request-body.test.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { waitForError } from '@sentry-internal/test-utils';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-test('keeps the body of a request that is not a tunnel request off its error event', async ({ request }) => {
- const errorPromise = waitForError('nuxt-4-cloudflare', event => event.exception?.values?.[0]?.value === 'POST error');
-
- await request.post('/app/api/post-error', { data: { note: 'stays off the event' } });
- const error = await errorPromise;
-
- expect(error.request?.method).toBe('POST');
- expect(error.request?.data).toBeUndefined();
-});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tests/tunnel.test.ts
deleted file mode 100644
index 33c00290d888..000000000000
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tests/tunnel.test.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { isServerSpanAt, makeClientReportEnvelope, watchForTunnelSpan } from '@sentry-internal/test-utils';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-// The isolate's first tunnel request is the one a late span filter would let through, so this stays the only test.
-test('answers the managed tunnel set up by `sentryCloudflareNitroPlugin`, without a span of it', async ({
- request,
-}) => {
- const dsn = 'http://public@localhost:3031/1337';
- const raceTunnelSpan = watchForTunnelSpan('nuxt-4-cloudflare', isServerSpanAt(/^\/app\/qpo967/));
-
- // The path the SDK derives from `dsn`.
- const response = await request.post('/app/qpo967', {
- data: makeClientReportEnvelope(dsn),
- headers: { 'Content-Type': 'application/x-sentry-envelope' },
- });
-
- expect(response.status()).toBe(200);
- expect(await raceTunnelSpan(isServerSpanAt('/app/api/anchor'), () => request.get('/app/api/anchor'))).toBe('anchor');
-});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-static/package.json b/dev-packages/e2e-tests/test-applications/nuxt-4-static/package.json
index 2f318a648dd3..bc5c2e479f7f 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-static/package.json
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-static/package.json
@@ -26,15 +26,18 @@
},
"devDependencies": {
"@playwright/test": "1.64.1",
- "@sentry/conventions": "0.32.0",
+ "@sentry/conventions": "0.33.0",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
},
"sentryTest": {
+ "baseVariant": {
+ "assert-command": "pnpm test:prod"
+ },
"variants": [
{
- "build-command": "E2E_TEST_OTEL_SETUP=true pnpm test:build",
- "assert-command": "E2E_TEST_OTEL_SETUP=true pnpm test:assert",
- "label": "nuxt-4-static (tracer provider)"
+ "build-command": "pnpm install",
+ "assert-command": "pnpm test:dev",
+ "label": "nuxt-4-static (development)"
}
],
"canaryVariants": [
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-static/sentry.server.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-static/sentry.server.config.ts
index d954cf92b242..af2cc3c0eaf2 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4-static/sentry.server.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-static/sentry.server.config.ts
@@ -5,9 +5,6 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0, // Capture 100% of the transactions
tunnel: 'http://localhost:3031/', // proxy server
- // Opt into the Sentry OpenTelemetry tracer provider in the "(tracer provider)" e2e variant.
- // Leaving it `undefined` otherwise keeps the SDK's default (no provider).
- enableOpenTelemetrySetup: process.env.E2E_TEST_OTEL_SETUP === 'true' ? true : undefined,
// Several tests trigger the same server error one after another, which Dedupe would drop.
integrations: integrations => integrations.filter(integration => integration.name !== 'Dedupe'),
});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/app/app.vue b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/app/app.vue
new file mode 100644
index 000000000000..749f7b309006
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/app/app.vue
@@ -0,0 +1,3 @@
+
+
Nuxt Tunnel E2E Test
+
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/nuxt.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/nuxt.config.ts
new file mode 100644
index 000000000000..db89bde2156a
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/nuxt.config.ts
@@ -0,0 +1,16 @@
+export default defineNuxtConfig({
+ compatibilityDate: '2025-06-06',
+ modules: ['@sentry/nuxt/module'],
+ app: { baseURL: '/app/' },
+ // A headers rule on every path, like a security headers setup, also covers the tunnel's path.
+ routeRules: { '/**': { headers: { 'x-e2e-route-rule': '1' } } },
+ nitro:
+ process.env.RUNTIME === 'cloudflare'
+ ? {
+ preset: 'cloudflare_module',
+ cloudflare: { nodeCompat: true, deployConfig: false },
+ // Cloudflare has no server config file, the SDK is set up by this plugin.
+ plugins: ['~~/server/sentry-cloudflare.ts'],
+ }
+ : {},
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/package.json b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/package.json
new file mode 100644
index 000000000000..f968a152d3b6
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "nuxt-4-tunnel",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "build": "nuxt build",
+ "start": "node .output/server/index.mjs",
+ "start:cloudflare": "wrangler dev --port 3030",
+ "clean": "npx nuxi cleanup",
+ "test:build": "pnpm install && pnpm build",
+ "test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
+ },
+ "dependencies": {
+ "@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
+ "@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz",
+ "nuxt": "^4.6.0"
+ },
+ "devDependencies": {
+ "@playwright/test": "1.64.1",
+ "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
+ "wrangler": "^4.72.0"
+ },
+ "sentryTest": {
+ "variants": [
+ {
+ "runtime": "cloudflare",
+ "build-command": "rm sentry.server.config.ts && pnpm test:build",
+ "assert-command": "TEST_ENV=production pnpm exec playwright test",
+ "label": "nuxt-4-tunnel (cloudflare)"
+ }
+ ]
+ }
+}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/playwright.config.mjs
new file mode 100644
index 000000000000..de8b29dac78e
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/playwright.config.mjs
@@ -0,0 +1,10 @@
+import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils';
+
+export default getPlaywrightConfig({
+ startCommand:
+ process.env.TEST_ENV === 'development'
+ ? 'pnpm exec nuxt dev -p 3030'
+ : getRuntime() === 'cloudflare'
+ ? 'pnpm start:cloudflare'
+ : 'pnpm start',
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/pnpm-workspace.yaml
new file mode 100644
index 000000000000..fd29a82085e0
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/pnpm-workspace.yaml
@@ -0,0 +1,4 @@
+allowBuilds:
+ esbuild: true
+ workerd: true
+minimumReleaseAge: 0
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/sentry.client.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/sentry.client.config.ts
new file mode 100644
index 000000000000..9ed4723ab8d5
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/sentry.client.config.ts
@@ -0,0 +1,8 @@
+import * as Sentry from '@sentry/nuxt';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ tunnel: true,
+ integrations: [Sentry.browserTracingIntegration()],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/sentry.server.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/sentry.server.config.ts
new file mode 100644
index 000000000000..3bd4355005e0
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/sentry.server.config.ts
@@ -0,0 +1,7 @@
+import * as Sentry from '@sentry/nuxt';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [Sentry.serveTunnelIntegration()],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/api/anchor.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/api/anchor.ts
new file mode 100644
index 000000000000..9915c0ba54ec
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/api/anchor.ts
@@ -0,0 +1,3 @@
+import { defineEventHandler } from '#imports';
+
+export default defineEventHandler(() => ({ ok: true }));
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/api/error.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/api/error.ts
new file mode 100644
index 000000000000..32e2c4437d38
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/api/error.ts
@@ -0,0 +1,5 @@
+import { defineEventHandler } from '#imports';
+
+export default defineEventHandler(() => {
+ throw new Error('Tunnel test error');
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/middleware/auth.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/middleware/auth.ts
new file mode 100644
index 000000000000..722383e39059
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/middleware/auth.ts
@@ -0,0 +1,7 @@
+import { createError, defineEventHandler, getHeader } from '#imports';
+
+export default defineEventHandler(event => {
+ if (event.method === 'POST' && getHeader(event, 'x-auth') !== 'ok') {
+ throw createError({ statusCode: 401, statusMessage: 'blocked by user auth' });
+ }
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/sentry-cloudflare.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/sentry-cloudflare.ts
new file mode 100644
index 000000000000..28d5302028a2
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/server/sentry-cloudflare.ts
@@ -0,0 +1,11 @@
+import { defineNitroPlugin } from '#imports';
+import { serveTunnelIntegration } from '@sentry/cloudflare';
+import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins';
+
+export default defineNitroPlugin(
+ sentryCloudflareNitroPlugin({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [serveTunnelIntegration()],
+ tracesSampleRate: 1,
+ }),
+);
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/start-event-proxy.mjs
new file mode 100644
index 000000000000..46d252a9ad78
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/start-event-proxy.mjs
@@ -0,0 +1,6 @@
+import { startEventProxyServer } from '@sentry-internal/test-utils';
+
+startEventProxyServer({
+ port: 3031,
+ proxyServerName: 'nuxt-4-tunnel',
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/tests/request-body.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/tests/request-body.test.ts
new file mode 100644
index 000000000000..c0bb953670c3
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/tests/request-body.test.ts
@@ -0,0 +1,16 @@
+import { expect, test } from '@playwright/test';
+import { getRuntime, waitForError } from '@sentry-internal/test-utils';
+
+test('keeps the body of a request that is not a tunnel request off its error event', async ({ request }) => {
+ test.skip(getRuntime() !== 'cloudflare', 'Only the Cloudflare plugin decides which request bodies it passes on');
+ const errorPromise = waitForError(
+ 'nuxt-4-tunnel',
+ event => event.exception?.values?.[0]?.value === 'Tunnel test error',
+ );
+
+ await request.post('/app/api/error', { data: { note: 'stays off the event' }, headers: { 'x-auth': 'ok' } });
+ const error = await errorPromise;
+
+ expect(error.request?.method).toBe('POST');
+ expect(error.request?.data).toBeUndefined();
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/tests/tunnel.test.ts
new file mode 100644
index 000000000000..1a37f467919d
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/tests/tunnel.test.ts
@@ -0,0 +1,14 @@
+import { expect, test } from '@playwright/test';
+import { getRuntime } from '@sentry-internal/test-utils';
+import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';
+
+// On Nitro v2, `sentryCloudflareNitroPlugin` checks for a tunnel request before the SDK has a client, so it never
+// passes the request body on and the app answers the tunnel instead.
+test.fixme(getRuntime() === 'cloudflare', 'The managed tunnel is not served on Cloudflare yet');
+
+test.beforeAll(async ({ request }) => {
+ // `nuxt dev` opens the port before it's ready and answers 503 until then, and Playwright only waits for the port.
+ await expect.poll(async () => (await request.get('/app/')).status(), { timeout: 30_000 }).not.toBe(503);
+});
+
+runManagedTunnelSuite({ appName: 'nuxt-4-tunnel', basePath: '/app' });
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/wrangler.jsonc b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/wrangler.jsonc
new file mode 100644
index 000000000000..2ee9dcb07374
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4-tunnel/wrangler.jsonc
@@ -0,0 +1,7 @@
+{
+ "name": "nuxt-4-tunnel",
+ "main": "./.output/server/index.mjs",
+ "compatibility_date": "2026-06-29",
+ "compatibility_flags": ["nodejs_compat"],
+ "assets": { "directory": "./.output/public", "binding": "ASSETS" },
+}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/nuxt.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4/nuxt.config.ts
index 272aaf5061c7..25a1fbdb8297 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4/nuxt.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4/nuxt.config.ts
@@ -1,5 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
-const tunnelVariant = !!process.env.E2E_TEST_TUNNEL;
export default defineNuxtConfig({
compatibilityDate: '2025-06-06',
@@ -13,21 +12,14 @@ export default defineNuxtConfig({
'/rendering-modes/swr-cached-page': { swr: true },
'/rendering-modes/swr-1h-cached-page': { swr: 3600 },
'/rendering-modes/pre-rendered-page': { prerender: true },
- // A headers rule on every path, like a security headers setup, also covers the tunnel's path.
- ...(tunnelVariant && { '/**': { headers: { 'x-e2e-route-rule': '1' } } }),
},
- // The base-path variant serves the app, and so the tunnel, under `/app`.
- ...(process.env.E2E_TEST_BASE_PATH && { app: { baseURL: `${process.env.E2E_TEST_BASE_PATH}/` } }),
-
modules: ['@pinia/nuxt', '@sentry/nuxt/module'],
runtimeConfig: {
public: {
sentry: {
- // The tunnel variant forwards to the test proxy, so the DSN has to point there.
- dsn: tunnelVariant ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
},
- e2eTunnel: tunnelVariant,
},
},
nitro: {
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/package.json b/dev-packages/e2e-tests/test-applications/nuxt-4/package.json
index 35f5a25b7a42..878785481cd8 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4/package.json
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4/package.json
@@ -16,10 +16,7 @@
"test:build": "pnpm install && node ./scripts/build-with-prerender-event-sink.mjs",
"test:build-canary": "pnpm add nuxt@npm:nuxt-nightly@latest && pnpm add nitropack@npm:nitropack-nightly@latest && pnpm install --force && node ./scripts/build-with-prerender-event-sink.mjs",
"test:assert": "pnpm test:prod && pnpm test:dev",
- "test:prod:import": "TEST_ENV=production-import playwright test",
- "test:build:tunnel-basepath": "pnpm install && E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app node ./scripts/build-with-prerender-event-sink.mjs",
- "test:assert:tunnel-basepath": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app TEST_ENV=production playwright test tunnel",
- "test:assert:tunnel-basepath-dev": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app TEST_ENV=development playwright test tunnel"
+ "test:prod:import": "TEST_ENV=production-import playwright test"
},
"//": "Pin ioredis to 5.10.1 because that's the last version before it publishes its own diagnostics channels",
"dependencies": {
@@ -32,34 +29,20 @@
},
"devDependencies": {
"@playwright/test": "1.64.1",
+ "@sentry/conventions": "0.33.0",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
},
"sentryTest": {
"variants": [
{
- "build-command": "E2E_TEST_OTEL_SETUP=true pnpm test:build",
- "assert-command": "E2E_TEST_OTEL_SETUP=true pnpm test:assert",
- "label": "nuxt-4 (tracer provider)"
- },
- {
- "build-command": "pnpm test:build",
- "assert-command": "pnpm test:prod:import",
- "label": "nuxt-4 (--import compat)"
+ "build-command": "pnpm install",
+ "assert-command": "pnpm test:dev",
+ "label": "nuxt-4 (development)"
},
{
"build-command": "E2E_TEST_VITE_SERVER=true pnpm test:build",
"assert-command": "E2E_TEST_VITE_SERVER=true pnpm test:prod",
"label": "nuxt-4 (Vite server)"
- },
- {
- "build-command": "pnpm test:build:tunnel-basepath",
- "assert-command": "pnpm test:assert:tunnel-basepath",
- "label": "nuxt-4 (tunnel-basepath)"
- },
- {
- "build-command": "pnpm install",
- "assert-command": "pnpm test:assert:tunnel-basepath-dev",
- "label": "nuxt-4 (tunnel-basepath-dev)"
}
],
"canaryVariants": [
@@ -67,6 +50,9 @@
"build-command": "pnpm test:build-canary",
"label": "nuxt-4 (canary)"
}
- ]
+ ],
+ "baseVariant": {
+ "assert-command": "pnpm test:prod"
+ }
}
}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.client.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.client.config.ts
index 64c786d5f7e8..7b5d97ff0b09 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.client.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.client.config.ts
@@ -3,7 +3,7 @@ import { usePinia, useRuntimeConfig } from '#imports';
Sentry.init({
dsn: useRuntimeConfig().public.sentry.dsn,
- tunnel: useRuntimeConfig().public.e2eTunnel ? true : `http://localhost:3031/`, // proxy server
+ tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1.0,
integrations: [
Sentry.piniaIntegration(usePinia(), {
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.server.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.server.config.ts
index c956224de1fc..d0d6327fb7ce 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.server.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4/sentry.server.config.ts
@@ -1,15 +1,9 @@
import * as Sentry from '@sentry/nuxt';
Sentry.init({
- dsn: process.env.E2E_TEST_TUNNEL ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0, // Capture 100% of the transactions
tunnel: 'http://localhost:3031/', // proxy server
- // Opt into the Sentry OpenTelemetry tracer provider in the "(tracer provider)" e2e variant.
- // Leaving it `undefined` otherwise keeps the SDK's default (no provider).
- enableOpenTelemetrySetup: process.env.E2E_TEST_OTEL_SETUP === 'true' ? true : undefined,
// Several tests trigger the same server error one after another, which Dedupe would drop.
- integrations: integrations => [
- ...integrations.filter(integration => integration.name !== 'Dedupe'),
- ...(process.env.E2E_TEST_TUNNEL ? [Sentry.serveTunnelIntegration()] : []),
- ],
+ integrations: integrations => [...integrations.filter(integration => integration.name !== 'Dedupe')],
});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/server/middleware/03.auth.ts b/dev-packages/e2e-tests/test-applications/nuxt-4/server/middleware/03.auth.ts
index 471d1d32d7a4..6dcd9a075589 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4/server/middleware/03.auth.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4/server/middleware/03.auth.ts
@@ -1,11 +1,6 @@
-import { createError, defineEventHandler, getHeader, setHeader, getQuery } from '#imports';
+import { defineEventHandler, setHeader, getQuery } from '#imports';
export default defineEventHandler(async event => {
- // The tunnel variant checks that the managed tunnel answers before an auth middleware like this one.
- if (process.env.E2E_TEST_TUNNEL && event.method === 'POST' && getHeader(event, 'x-auth') !== 'ok') {
- throw createError({ statusCode: 401, statusMessage: 'blocked by user auth' });
- }
-
// Check if we should throw an error
const query = getQuery(event);
if (query.throwError === 'true') {
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/tests/tracing.cached-html.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-4/tests/tracing.cached-html.test.ts
index 42ed5115020c..0537d1703b76 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-4/tests/tracing.cached-html.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-4/tests/tracing.cached-html.test.ts
@@ -1,4 +1,5 @@
import { expect, test, type Page } from '@playwright/test';
+import { PAGE_SERVER_RENDERING_TYPE, SENTRY_LINK_TYPE } from '@sentry/conventions/attributes';
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
import { isViteServer, NO_META_TAGS } from './isViteServer';
@@ -18,16 +19,19 @@ test.describe('Rendering Modes with Cached HTML', () => {
await testChangingTracingMetaTagsOnISRPage(page, '/rendering-modes/isr-1h-cached-page', 'ISR 1h Cached Page');
});
- test('exclude tracing meta tags on SWR-cached page', async ({ page }) => {
- await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/swr-cached-page', 'SWR Cached Page');
+ test('links the render as cache origin on SWR-cached page', async ({ page }) => {
+ test.fail(isViteServer, NO_META_TAGS);
+ await testCacheOriginOnRuntimeCachedPage(page, '/rendering-modes/swr-cached-page', 'SWR Cached Page');
});
- test('exclude tracing meta tags on SWR 1h cached page', async ({ page }) => {
- await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/swr-1h-cached-page', 'SWR 1h Cached Page');
+ test('links the render as cache origin on SWR 1h cached page', async ({ page }) => {
+ test.fail(isViteServer, NO_META_TAGS);
+ await testCacheOriginOnRuntimeCachedPage(page, '/rendering-modes/swr-1h-cached-page', 'SWR 1h Cached Page');
});
- test('exclude tracing meta tags on pre-rendered page', async ({ page }) => {
- await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/pre-rendered-page', 'Pre-Rendered Page');
+ test('marks pageloads of pre-rendered page as static without a cache origin link', async ({ page }) => {
+ test.fail(isViteServer, NO_META_TAGS);
+ await testEmptyCacheOriginOnPrerenderedPage(page, '/rendering-modes/pre-rendered-page', 'Pre-Rendered Page');
});
});
@@ -122,26 +126,36 @@ export async function testChangingTracingMetaTagsOnISRPage(
});
}
+async function getCacheOriginMetaTag(page: Page): Promise {
+ await expect(page.locator('meta[name="sentry-cache-origin"]')).toHaveCount(1);
+ expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
+ expect(await page.locator('meta[name="baggage"]').count()).toBe(0);
+ return page.locator('meta[name="sentry-cache-origin"]').getAttribute('content');
+}
+
+async function getRenderStart(page: Page): Promise {
+ await expect(page.locator('meta[name="sentry-render-start"]')).toHaveCount(1);
+ return Number(await page.locator('meta[name="sentry-render-start"]').getAttribute('content'));
+}
+
+const PAGE_SERVER_RENDERING_AGE = 'page.server_rendering.age';
+
+function expectedRenderAge(pageloadStart: number, renderStart: number): number {
+ return Math.max(0, Math.floor(pageloadStart - renderStart));
+}
+
/**
- * Tests that tracing meta-tags are excluded on cached pages (SWR, pre-rendered, etc.)
- * This utility handles the common pattern of:
- * 1. Making two requests to a cached page
- * 2. Verifying no tracing meta-tags are present
- * 3. Verifying traces are not distributed (each pageload starts its own trace)
- *
- * @param page - Playwright page object
- * @param routePath - The route path to test (e.g., '/rendering-modes/swr-cached-page')
- * @param expectedPageText - The text to verify is visible on the page (e.g., 'SWR Cached Page')
+ * Tests a page that a route rule caches at runtime. The cached HTML holds the `sentry-trace` value of
+ * the render in a `sentry-cache-origin` tag. Every pageload starts its own trace, is static, and links
+ * the render.
*/
-export async function testExcludeTracingMetaTagsOnCachedPage(
+export async function testCacheOriginOnRuntimeCachedPage(
page: Page,
routePath: string,
expectedPageText: string,
): Promise {
- // === 1. Request ===
+ // === 1. Request (renders and fills the cache) ===
const clientSpanPromise1 = waitForPageloadSegment(routePath);
-
- // Only the 1. request creates a server root span
const serverSpanPromise1 = waitForServerSegment(routePath);
const [_1, clientSpan1, serverSpan1] = await Promise.all([
@@ -150,13 +164,10 @@ export async function testExcludeTracingMetaTagsOnCachedPage(
serverSpanPromise1,
expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
]);
+ const cacheOrigin1 = await getCacheOriginMetaTag(page);
+ const renderStart1 = await getRenderStart(page);
- // Verify no baggage and sentry-trace meta-tags are present on first request
- expect(await page.locator('meta[name="baggage"]').count()).toBe(0);
- expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
-
- // === 2. Request ===
-
+ // === 2. Request (served from the cache) ===
const clientSpanPromise2 = waitForPageloadSegment(routePath);
const [_2, clientSpan2] = await Promise.all([
@@ -164,30 +175,97 @@ export async function testExcludeTracingMetaTagsOnCachedPage(
clientSpanPromise2,
expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
]);
+ const cacheOrigin2 = await getCacheOriginMetaTag(page);
+ const renderStart2 = await getRenderStart(page);
+
+ const [originTraceId, originSpanId, originSampled] = cacheOrigin1?.split('-') ?? [];
+ const cacheOriginLink = {
+ trace_id: serverSpan1.trace_id,
+ span_id: serverSpan1.span_id,
+ sampled: true,
+ attributes: { [SENTRY_LINK_TYPE]: { type: 'string', value: 'cache_origin' } },
+ };
+
+ await test.step('The cache origin tag holds the `http.server` root span of the 1. request', () => {
+ expect(originTraceId).toBe(serverSpan1.trace_id);
+ expect(originSpanId).toBe(serverSpan1.span_id);
+ expect(originSampled).toBe('1');
+ expect(cacheOrigin2).toBe(cacheOrigin1);
+ });
- const clientSpan1TraceId = clientSpan1.trace_id;
- const clientSpan2TraceId = clientSpan2.trace_id;
-
- const serverSpan1TraceId = serverSpan1.trace_id;
+ await test.step('Every pageload starts its own trace', () => {
+ expect(clientSpan1.parent_span_id).toBeUndefined();
+ expect(clientSpan2.parent_span_id).toBeUndefined();
+ expect(clientSpan1.trace_id).not.toBe(serverSpan1.trace_id);
+ expect(clientSpan2.trace_id).not.toBe(serverSpan1.trace_id);
+ expect(clientSpan1.trace_id).not.toBe(clientSpan2.trace_id);
+ });
- await test.step('No baggage and sentry-trace meta-tags are present on second request', async () => {
- expect(await page.locator('meta[name="baggage"]').count()).toBe(0);
- expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
+ await test.step('Every pageload is static and links the render', () => {
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan1.links).toEqual([cacheOriginLink]);
+ expect(clientSpan2.links).toEqual([cacheOriginLink]);
});
- await test.step('1. server root span and all client root spans are defined', () => {
- expect(serverSpan1TraceId).toBeDefined();
- expect(clientSpan1TraceId).toBeDefined();
- expect(clientSpan2TraceId).toBeDefined();
+ await test.step('Every pageload has the age of the render, which started with the 1. request', () => {
+ expect(renderStart1).toBe(Math.floor(serverSpan1.start_timestamp));
+ expect(renderStart2).toBe(renderStart1);
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan1.start_timestamp, renderStart1),
+ });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan2.start_timestamp, renderStart1),
+ });
});
+}
- await test.step('Trace is not distributed', () => {
- // Cannot create distributed trace as HTML Meta Tags are not added (caching leads to multiple usages of the same server trace id)
- expect(clientSpan1TraceId).not.toBe(clientSpan2TraceId);
- expect(clientSpan1TraceId).not.toBe(serverSpan1TraceId);
- expect(clientSpan2TraceId).not.toBe(serverSpan1TraceId);
- // Without meta tags the pageloads have no parent and start their own traces
- expect(clientSpan1.parent_span_id).toBeUndefined();
- expect(clientSpan2.parent_span_id).toBeUndefined();
+/**
+ * Tests a page that Nitro prerendered during the build. The SDK does not run in the build, so the
+ * `sentry-cache-origin` tag is empty: every pageload starts its own trace and is static, without a link.
+ */
+export async function testEmptyCacheOriginOnPrerenderedPage(
+ page: Page,
+ routePath: string,
+ expectedPageText: string,
+): Promise {
+ const clientSpanPromise1 = waitForPageloadSegment(routePath);
+ const [_1, clientSpan1] = await Promise.all([
+ page.goto(routePath),
+ clientSpanPromise1,
+ expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
+ ]);
+ const cacheOrigin1 = await getCacheOriginMetaTag(page);
+ const renderStart1 = await getRenderStart(page);
+
+ const clientSpanPromise2 = waitForPageloadSegment(routePath);
+ const [_2, clientSpan2] = await Promise.all([
+ page.goto(routePath),
+ clientSpanPromise2,
+ expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
+ ]);
+ const cacheOrigin2 = await getCacheOriginMetaTag(page);
+ const renderStart2 = await getRenderStart(page);
+
+ expect(cacheOrigin1).toBe('');
+ expect(cacheOrigin2).toBe('');
+ expect(clientSpan1.parent_span_id).toBeUndefined();
+ expect(clientSpan2.parent_span_id).toBeUndefined();
+ expect(clientSpan1.trace_id).not.toBe(clientSpan2.trace_id);
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan1.links).toBeUndefined();
+ expect(clientSpan2.links).toBeUndefined();
+ // The build rendered the page, so the render start is the time of the build.
+ expect(renderStart2).toBe(renderStart1);
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan1.start_timestamp, renderStart1),
+ });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan2.start_timestamp, renderStart1),
});
}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-4/tests/tunnel.test.ts
deleted file mode 100644
index cad4d5db942c..000000000000
--- a/dev-packages/e2e-tests/test-applications/nuxt-4/tests/tunnel.test.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { expect, test } from '@playwright/test';
-import {
- isServerSpanAt,
- makeClientReportEnvelope,
- waitForError,
- watchForTunnelSpan,
-} from '@sentry-internal/test-utils';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-test.beforeAll(async ({ request }) => {
- // `nuxt dev` opens the port before it's ready and answers 503 until then, and Playwright only waits for the port.
- await expect
- .poll(async () => (await request.get(`${process.env.E2E_TEST_BASE_PATH ?? ''}/`)).status(), { timeout: 30_000 })
- .not.toBe(503);
-});
-
-const BASE_PATH = process.env.E2E_TEST_BASE_PATH ?? '';
-const TUNNEL_PATH = new RegExp(`^${BASE_PATH}/[a-z0-9]{1,7}$`);
-
-test('answers the managed tunnel before the app auth middleware', async ({ page }) => {
- // The variant's auth middleware rejects every other POST.
- expect((await page.request.post(`${BASE_PATH}/api/anything`, { data: 'x' })).status()).toBe(401);
-
- const raceTunnelSpan = watchForTunnelSpan('nuxt-4', isServerSpanAt(TUNNEL_PATH));
- const tunnelResponsePromise = page.waitForResponse(
- response => response.request().method() === 'POST' && TUNNEL_PATH.test(new URL(response.url()).pathname),
- );
-
- await page.goto(`${BASE_PATH}/`);
-
- expect((await tunnelResponsePromise).status()).toBe(200);
- expect(
- await raceTunnelSpan(isServerSpanAt(`${BASE_PATH}/api/test-param/123`), () =>
- page.request.get(`${BASE_PATH}/api/test-param/123`),
- ),
- ).toBe('anchor');
-});
-
-test('answers the managed tunnel once, without errors from route rules that run after it', async ({ request }) => {
- const dsn = 'http://public@localhost:3031/1337';
- // The path the SDK derives from `dsn`.
- const tunnelPath = '/qpo967';
- const tunnelErrorPromise = waitForError(
- 'nuxt-4',
- event => !!event.exception?.values?.[0]?.value?.includes('Cannot set headers'),
- );
- const anchorErrorPromise = waitForError(
- 'nuxt-4',
- event => event.exception?.values?.[0]?.value === 'Nuxt 4 Server error',
- );
-
- const response = await request.post(`${BASE_PATH}${tunnelPath}`, {
- data: makeClientReportEnvelope(dsn),
- headers: { 'Content-Type': 'application/x-sentry-envelope' },
- });
- expect(response.status()).toBe(200);
-
- // Errors are sent in order, so one from the tunnel request would arrive before this later one.
- await request.get(`${BASE_PATH}/api/server-error`);
-
- const winner = await Promise.race([
- tunnelErrorPromise.then(() => 'tunnel' as const),
- anchorErrorPromise.then(() => 'anchor' as const),
- ]);
- expect(winner).toBe('anchor');
-});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/nuxt.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/nuxt.config.ts
index eebfc18d5191..107f439a3c53 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/nuxt.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/nuxt.config.ts
@@ -2,17 +2,11 @@
export default defineNuxtConfig({
compatibilityDate: '2025-06-06',
modules: ['@sentry/nuxt/module'],
- // The tunnel variant serves the app, and so the tunnel, under a base URL.
- ...(process.env.E2E_TEST_TUNNEL && { app: { baseURL: '/app/' } }),
nitro: {
preset: 'cloudflare_module',
cloudflare: {
nodeCompat: true,
deployConfig: false,
},
- // The tunnel variant serves the managed tunnel.
- replace: {
- __E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
- },
},
});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/package.json b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/package.json
index cef0544fdde3..b681f9ed4b51 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/package.json
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/package.json
@@ -8,9 +8,7 @@
"preview": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --port 3030 --log-level=$(test $CI && echo 'none' || echo 'log')",
"test": "playwright test",
"test:build": "pnpm install && pnpm build",
- "test:assert": "pnpm test",
- "test:build:tunnel": "pnpm install && E2E_TEST_TUNNEL=1 pnpm build",
- "test:assert:tunnel": "E2E_TEST_TUNNEL=1 pnpm test tunnel"
+ "test:assert": "pnpm test"
},
"//": [
"Nuxt v5 is only on the Nuxt nightlies, like the `nuxt-5` app.",
@@ -29,13 +27,6 @@
"wrangler": "^4.72.0"
},
"sentryTest": {
- "optional": true,
- "variants": [
- {
- "build-command": "pnpm test:build:tunnel",
- "assert-command": "pnpm test:assert:tunnel",
- "label": "nuxt-5-cloudflare (tunnel)"
- }
- ]
+ "optional": true
}
}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/api/anchor.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/api/anchor.ts
index 63c9ceb606e9..dbaf5fea80d5 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/api/anchor.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/api/anchor.ts
@@ -1,4 +1,4 @@
import { defineHandler } from 'nitro';
-// A plain route for tests to request after the tunnel traffic.
+// A plain route for tests to request.
export default defineHandler(() => 'ok');
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/plugins/sentry.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/plugins/sentry.ts
index 8368a5a85dde..36ce35d46765 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/plugins/sentry.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/server/plugins/sentry.ts
@@ -1,15 +1,10 @@
import { definePlugin } from 'nitro';
-import { serveTunnelIntegration } from '@sentry/cloudflare';
import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins';
-declare const __E2E_TEST_TUNNEL__: boolean;
-
export default definePlugin(
sentryCloudflareNitroPlugin({
- // The tunnel forwards to the DSN host, which is the event proxy in the tunnel variant.
- dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
- integrations: __E2E_TEST_TUNNEL__ ? [serveTunnelIntegration()] : [],
}),
);
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/tests/tunnel.test.ts
deleted file mode 100644
index 8c54796751c6..000000000000
--- a/dev-packages/e2e-tests/test-applications/nuxt-5-cloudflare/tests/tunnel.test.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { isServerSpanAt, makeClientReportEnvelope, watchForTunnelSpan } from '@sentry-internal/test-utils';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-// The isolate's first tunnel request is the one a late span filter would let through, so this stays the only test.
-test('answers the managed tunnel set up by `sentryCloudflareNitroPlugin`, without a span of it', async ({
- request,
-}) => {
- const dsn = 'http://public@localhost:3031/1337';
- const raceTunnelSpan = watchForTunnelSpan('nuxt-5-cloudflare', isServerSpanAt(/^\/app\/qpo967/));
-
- // The path the SDK derives from `dsn`.
- const response = await request.post('/app/qpo967', {
- data: makeClientReportEnvelope(dsn),
- headers: { 'Content-Type': 'application/x-sentry-envelope' },
- });
-
- expect(response.status()).toBe(200);
- expect(await raceTunnelSpan(isServerSpanAt('/app/api/anchor'), () => request.get('/app/api/anchor'))).toBe('anchor');
-});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-sourcemaps/package.json b/dev-packages/e2e-tests/test-applications/nuxt-5-sourcemaps/package.json
index e2d35fd304b3..af833ac3a1bf 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5-sourcemaps/package.json
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-sourcemaps/package.json
@@ -16,7 +16,8 @@
"dependencies": {
"@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz",
"nitro": "latest",
- "nuxt": "npm:nuxt-nightly@5x"
+ "nuxt": "npm:nuxt-nightly@5x",
+ "vue-router": "^5.5.0"
},
"devDependencies": {
"@playwright/test": "1.64.1",
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/app/app.vue b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/app/app.vue
new file mode 100644
index 000000000000..749f7b309006
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/app/app.vue
@@ -0,0 +1,3 @@
+
+
Nuxt Tunnel E2E Test
+
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/nuxt.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/nuxt.config.ts
new file mode 100644
index 000000000000..8a71fcfbc94d
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/nuxt.config.ts
@@ -0,0 +1,16 @@
+export default defineNuxtConfig({
+ compatibilityDate: '2025-07-15',
+ modules: ['@sentry/nuxt/module'],
+ app: { baseURL: '/app/' },
+ // A headers rule on every path, like a security headers setup, also covers the tunnel's path.
+ routeRules: { '/**': { headers: { 'x-e2e-route-rule': '1' } } },
+ nitro:
+ process.env.RUNTIME === 'cloudflare'
+ ? {
+ preset: 'cloudflare_module',
+ cloudflare: { nodeCompat: true, deployConfig: false },
+ // Cloudflare has no server config file, the SDK is set up by this plugin.
+ plugins: ['~~/server/sentry-cloudflare.ts'],
+ }
+ : {},
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/package.json b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/package.json
new file mode 100644
index 000000000000..31942d3ae264
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "nuxt-5-tunnel",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "build": "nuxt build",
+ "start": "node .output/server/index.mjs",
+ "start:cloudflare": "wrangler dev --port 3030",
+ "clean": "npx nuxi cleanup",
+ "test:build": "pnpm install && pnpm build",
+ "test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
+ },
+ "//": [
+ "Nuxt v5 is only on the Nuxt nightlies, like the `nuxt-5` app.",
+ "`ofetch` is a dependency of `nuxt`, which Nuxt's virtual `fetch.server.mjs` can't resolve from the app, see `nuxt-5`."
+ ],
+ "dependencies": {
+ "@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
+ "@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz",
+ "nuxt": "npm:nuxt-nightly@5x",
+ "ofetch": "^2.0.0-alpha.3",
+ "vue": "^3.5.41"
+ },
+ "devDependencies": {
+ "@playwright/test": "1.64.1",
+ "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
+ "wrangler": "^4.72.0"
+ },
+ "sentryTest": {
+ "optional": true,
+ "variants": [
+ {
+ "runtime": "cloudflare",
+ "build-command": "rm sentry.server.config.ts && pnpm test:build",
+ "assert-command": "TEST_ENV=production pnpm exec playwright test",
+ "label": "nuxt-5-tunnel (cloudflare)"
+ }
+ ]
+ }
+}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/playwright.config.mjs
new file mode 100644
index 000000000000..de8b29dac78e
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/playwright.config.mjs
@@ -0,0 +1,10 @@
+import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils';
+
+export default getPlaywrightConfig({
+ startCommand:
+ process.env.TEST_ENV === 'development'
+ ? 'pnpm exec nuxt dev -p 3030'
+ : getRuntime() === 'cloudflare'
+ ? 'pnpm start:cloudflare'
+ : 'pnpm start',
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/pnpm-workspace.yaml
new file mode 100644
index 000000000000..fd29a82085e0
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/pnpm-workspace.yaml
@@ -0,0 +1,4 @@
+allowBuilds:
+ esbuild: true
+ workerd: true
+minimumReleaseAge: 0
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/sentry.client.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/sentry.client.config.ts
new file mode 100644
index 000000000000..9ed4723ab8d5
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/sentry.client.config.ts
@@ -0,0 +1,8 @@
+import * as Sentry from '@sentry/nuxt';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ tunnel: true,
+ integrations: [Sentry.browserTracingIntegration()],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/sentry.server.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/sentry.server.config.ts
new file mode 100644
index 000000000000..3bd4355005e0
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/sentry.server.config.ts
@@ -0,0 +1,7 @@
+import * as Sentry from '@sentry/nuxt';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [Sentry.serveTunnelIntegration()],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/api/anchor.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/api/anchor.ts
new file mode 100644
index 000000000000..aaf5888558fa
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/api/anchor.ts
@@ -0,0 +1,3 @@
+import { defineHandler } from 'nitro';
+
+export default defineHandler(() => ({ ok: true }));
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/api/error.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/api/error.ts
new file mode 100644
index 000000000000..1b22b59ce8e7
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/api/error.ts
@@ -0,0 +1,5 @@
+import { defineHandler } from 'nitro';
+
+export default defineHandler(() => {
+ throw new Error('Tunnel test error');
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/middleware/auth.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/middleware/auth.ts
new file mode 100644
index 000000000000..c4b04da90ee5
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/middleware/auth.ts
@@ -0,0 +1,8 @@
+import { defineHandler } from 'nitro';
+import { HTTPError } from 'nitro/h3';
+
+export default defineHandler(event => {
+ if (event.req.method === 'POST') {
+ throw new HTTPError({ status: 401, statusText: 'blocked by user auth' });
+ }
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/sentry-cloudflare.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/sentry-cloudflare.ts
new file mode 100644
index 000000000000..2bec38837549
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/server/sentry-cloudflare.ts
@@ -0,0 +1,11 @@
+import { serveTunnelIntegration } from '@sentry/cloudflare';
+import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins';
+import { definePlugin } from 'nitro';
+
+export default definePlugin(
+ sentryCloudflareNitroPlugin({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [serveTunnelIntegration()],
+ tracesSampleRate: 1,
+ }),
+);
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/start-event-proxy.mjs
new file mode 100644
index 000000000000..cc3782470127
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/start-event-proxy.mjs
@@ -0,0 +1,6 @@
+import { startEventProxyServer } from '@sentry-internal/test-utils';
+
+startEventProxyServer({
+ port: 3031,
+ proxyServerName: 'nuxt-5-tunnel',
+});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/tests/tunnel.test.ts
new file mode 100644
index 000000000000..fb21b8813dbb
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/tests/tunnel.test.ts
@@ -0,0 +1,9 @@
+import { expect, test } from '@playwright/test';
+import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';
+
+test.beforeAll(async ({ request }) => {
+ // `nuxt dev` opens the port before it's ready and answers 503 until then, and Playwright only waits for the port.
+ await expect.poll(async () => (await request.get('/app/')).status(), { timeout: 30_000 }).not.toBe(503);
+});
+
+runManagedTunnelSuite({ appName: 'nuxt-5-tunnel', basePath: '/app' });
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/wrangler.jsonc b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/wrangler.jsonc
new file mode 100644
index 000000000000..262e6a5c1848
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5-tunnel/wrangler.jsonc
@@ -0,0 +1,7 @@
+{
+ "name": "nuxt-5-tunnel",
+ "main": "./.output/server/index.mjs",
+ "compatibility_date": "2026-06-29",
+ "compatibility_flags": ["nodejs_compat"],
+ "assets": { "directory": "./.output/public", "binding": "ASSETS" },
+}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/nuxt.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/nuxt.config.ts
index 78c559af3621..f81873ea0b21 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/nuxt.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/nuxt.config.ts
@@ -1,5 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
-const tunnelVariant = !!process.env.E2E_TEST_TUNNEL;
export default defineNuxtConfig({
compatibilityDate: '2025-07-15',
@@ -14,23 +13,16 @@ export default defineNuxtConfig({
'/rendering-modes/pre-rendered-page': { prerender: true },
},
- // The base-path variant serves the app, and so the tunnel, under `/app`.
- ...(process.env.E2E_TEST_BASE_PATH && { app: { baseURL: `${process.env.E2E_TEST_BASE_PATH}/` } }),
-
modules: ['@pinia/nuxt', '@sentry/nuxt/module'],
runtimeConfig: {
public: {
sentry: {
- // The tunnel variant forwards to the test proxy, so the DSN has to point there.
- dsn: tunnelVariant ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
},
- e2eTunnel: tunnelVariant,
},
},
nitro: {
- // Nitro v3 only routes `defineCachedFunction`/`defineCachedHandler` through KV storage (which the SDK
- // instruments) with the `kv` cache driver. The default `memory` driver bypasses KV storage entirely.
- cache: { driver: 'kv' },
+ ...(process.env.E2E_TEST_CACHE_DRIVER && { cache: { driver: process.env.E2E_TEST_CACHE_DRIVER } }),
experimental: {
database: true,
},
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/package.json b/dev-packages/e2e-tests/test-applications/nuxt-5/package.json
index 517736025e41..e60519f93601 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/package.json
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/package.json
@@ -16,9 +16,8 @@
"test:build": "pnpm install && pnpm build",
"test:build-canary": "pnpm add nuxt@npm:nuxt-nightly@latest && pnpm add nitro@npm:nitro-nightly@latest && pnpm install --force && pnpm build",
"test:assert": "pnpm test:prod && pnpm test:dev",
- "test:build:tunnel-basepath": "pnpm install && E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm build",
- "test:assert:tunnel-basepath": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app TEST_ENV=production playwright test tunnel",
- "test:assert:tunnel-dev": "E2E_TEST_TUNNEL=1 TEST_ENV=development playwright test tunnel"
+ "test:build:kv-cache": "pnpm install && E2E_TEST_CACHE_DRIVER=kv pnpm build",
+ "test:assert:kv-cache": "E2E_TEST_CACHE_DRIVER=kv TEST_ENV=production playwright test cache"
},
"//": [
"Currently, we need to install the Nuxt nightlies as those contain Nuxt v5",
@@ -33,26 +32,29 @@
"mongoose": "^9.10.2",
"ofetch": "^2.0.0-alpha.3",
"nuxt": "npm:nuxt-nightly@5x",
- "vue": "^3.5.41"
+ "vue": "^3.5.41",
+ "vue-router": "^5.5.0"
},
"devDependencies": {
"@playwright/test": "1.64.1",
+ "@sentry/conventions": "0.33.0",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
},
"sentryTest": {
"optional": true,
- "variants": [
- {
- "build-command": "pnpm test:build:tunnel-basepath",
- "assert-command": "pnpm test:assert:tunnel-basepath",
- "label": "nuxt-5 (tunnel-basepath)"
- }
- ],
+ "baseVariant": {
+ "assert-command": "pnpm test:prod"
+ },
"optionalVariants": [
{
"build-command": "pnpm install",
- "assert-command": "pnpm test:assert:tunnel-dev",
- "label": "nuxt-5 (tunnel-dev)"
+ "assert-command": "pnpm test:dev",
+ "label": "nuxt-5 (development)"
+ },
+ {
+ "build-command": "pnpm test:build:kv-cache",
+ "assert-command": "pnpm test:assert:kv-cache",
+ "label": "nuxt-5 (kv-cache)"
}
]
}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.client.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.client.config.ts
index f5a30830107b..900df0811faa 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.client.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.client.config.ts
@@ -3,7 +3,7 @@ import { /* usePinia,*/ useRuntimeConfig } from '#imports';
Sentry.init({
dsn: useRuntimeConfig().public.sentry.dsn,
- tunnel: useRuntimeConfig().public.e2eTunnel ? true : `http://localhost:3031/`, // proxy server
+ tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1.0,
integrations: [
/* Sentry.piniaIntegration(usePinia(), {
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.server.config.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.server.config.ts
index ab66d40e13c7..d0d6327fb7ce 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.server.config.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/sentry.server.config.ts
@@ -1,12 +1,9 @@
import * as Sentry from '@sentry/nuxt';
Sentry.init({
- dsn: process.env.E2E_TEST_TUNNEL ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0, // Capture 100% of the transactions
tunnel: 'http://localhost:3031/', // proxy server
// Several tests trigger the same server error one after another, which Dedupe would drop.
- integrations: integrations => [
- ...integrations.filter(integration => integration.name !== 'Dedupe'),
- ...(process.env.E2E_TEST_TUNNEL ? [Sentry.serveTunnelIntegration()] : []),
- ],
+ integrations: integrations => [...integrations.filter(integration => integration.name !== 'Dedupe')],
});
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/server/middleware/03-auth.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/server/middleware/03-auth.ts
index 62d2eebd07e0..e3edadba5b12 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/server/middleware/03-auth.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/server/middleware/03-auth.ts
@@ -2,11 +2,6 @@ import { defineHandler } from 'nitro';
import { getQuery, HTTPError } from 'nitro/h3';
export default defineHandler(async event => {
- // The tunnel variant checks that the managed tunnel answers before an auth middleware like this one.
- if (process.env.E2E_TEST_TUNNEL && event.req.method === 'POST' && event.req.headers.get('x-auth') !== 'ok') {
- throw new HTTPError({ status: 401, statusText: 'blocked by user auth' });
- }
-
// Check if we should throw an error
const query = getQuery(event);
if (query.throwError === 'true') {
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/cache.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/cache.test.ts
index 676ecc4ab91f..1cd62dbae4da 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/cache.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/cache.test.ts
@@ -1,6 +1,15 @@
import { expect, test } from '@playwright/test';
import { collectStreamedSpansUntilSegment } from '@sentry-internal/test-utils';
+// Nitro v3 only routes cached functions and handlers through KV storage with the `kv` cache driver,
+// so the default (`memory`) driver is traced through ocache's storage instead.
+const isKvCacheDriver = process.env.E2E_TEST_CACHE_DRIVER === 'kv';
+const GET_METHOD = isKvCacheDriver ? 'getItem' : 'get';
+const SET_METHOD = isKvCacheDriver ? 'setItem' : 'set';
+const STORAGE_ATTRIBUTES = isKvCacheDriver
+ ? { 'db.collection.name': { type: 'string', value: expect.stringMatching(/^(cache)?$/) } }
+ : { 'db.system.name': { type: 'string', value: 'memory' } };
+
test.describe('Cache Instrumentation', () => {
const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';
const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';
@@ -34,8 +43,8 @@ test.describe('Cache Instrumentation', () => {
const getCacheKey = (span: (typeof allCacheSpans)[number]) => span.attributes[SEMANTIC_ATTRIBUTE_CACHE_KEY]?.value;
- // Test getItem spans for cachedFunction - should have both cache miss and cache hit
- const getItemSpans = findSpansByMethod('getItem');
+ // Test read spans for cachedFunction - should have both cache miss and cache hit
+ const getItemSpans = findSpansByMethod(GET_METHOD);
expect(getItemSpans.length).toBeGreaterThan(0);
// Find cache miss (first call to getCachedUser('123'))
@@ -51,8 +60,8 @@ test.describe('Cache Instrumentation', () => {
'cache.operation': { type: 'string', value: 'get' },
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: false },
- 'db.operation.name': { type: 'string', value: 'getItem' },
- 'db.collection.name': { type: 'string', value: expect.stringMatching(/^(cache)?$/) },
+ 'db.operation.name': { type: 'string', value: GET_METHOD },
+ ...STORAGE_ATTRIBUTES,
});
}
@@ -69,13 +78,13 @@ test.describe('Cache Instrumentation', () => {
'cache.operation': { type: 'string', value: 'get' },
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
- 'db.operation.name': { type: 'string', value: 'getItem' },
- 'db.collection.name': { type: 'string', value: expect.stringMatching(/^(cache)?$/) },
+ 'db.operation.name': { type: 'string', value: GET_METHOD },
+ ...STORAGE_ATTRIBUTES,
});
}
- // Test setItem spans for cachedFunction - when cache miss occurs, value is set
- const setItemSpans = findSpansByMethod('setItem');
+ // Test write spans for cachedFunction - when cache miss occurs, value is set
+ const setItemSpans = findSpansByMethod(SET_METHOD);
expect(setItemSpans.length).toBeGreaterThan(0);
const cacheSetSpan = setItemSpans.find(
@@ -86,8 +95,8 @@ test.describe('Cache Instrumentation', () => {
'sentry.op': { type: 'string', value: 'cache.put' },
'cache.operation': { type: 'string', value: 'put' },
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
- 'db.operation.name': { type: 'string', value: 'setItem' },
- 'db.collection.name': { type: 'string', value: expect.stringMatching(/^(cache)?$/) },
+ 'db.operation.name': { type: 'string', value: SET_METHOD },
+ ...STORAGE_ATTRIBUTES,
});
}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/tracing.cached-html.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/tracing.cached-html.test.ts
index 90f197cd8641..d675dcab394c 100644
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/tracing.cached-html.test.ts
+++ b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/tracing.cached-html.test.ts
@@ -1,4 +1,5 @@
import { expect, test, type Page } from '@playwright/test';
+import { PAGE_SERVER_RENDERING_TYPE, SENTRY_LINK_TYPE } from '@sentry/conventions/attributes';
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
test.describe('Rendering Modes with Cached HTML', () => {
@@ -14,18 +15,16 @@ test.describe('Rendering Modes with Cached HTML', () => {
await testChangingTracingMetaTagsOnISRPage(page, '/rendering-modes/isr-1h-cached-page', 'ISR 1h Cached Page');
});
- // fixme
- test.skip('exclude tracing meta tags on SWR-cached page', async ({ page }) => {
- await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/swr-cached-page', 'SWR Cached Page');
+ test('links the render as cache origin on SWR-cached page', async ({ page }) => {
+ await testCacheOriginOnRuntimeCachedPage(page, '/rendering-modes/swr-cached-page', 'SWR Cached Page');
});
- // fixme
- test.skip('exclude tracing meta tags on SWR 1h cached page', async ({ page }) => {
- await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/swr-1h-cached-page', 'SWR 1h Cached Page');
+ test('links the render as cache origin on SWR 1h cached page', async ({ page }) => {
+ await testCacheOriginOnRuntimeCachedPage(page, '/rendering-modes/swr-1h-cached-page', 'SWR 1h Cached Page');
});
- test('exclude tracing meta tags on pre-rendered page', async ({ page }) => {
- await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/pre-rendered-page', 'Pre-Rendered Page');
+ test('marks pageloads of pre-rendered page as static without a cache origin link', async ({ page }) => {
+ await testEmptyCacheOriginOnPrerenderedPage(page, '/rendering-modes/pre-rendered-page', 'Pre-Rendered Page');
});
});
@@ -71,6 +70,7 @@ export async function testChangingTracingMetaTagsOnISRPage(
expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
]);
+ await expect(page.locator('meta[name="baggage"]')).toHaveCount(1);
const baggageMetaTagContent1 = await page.locator('meta[name="baggage"]').getAttribute('content');
const sentryTraceMetaTagContent1 = await page.locator('meta[name="sentry-trace"]').getAttribute('content');
const [htmlMetaTraceId1] = sentryTraceMetaTagContent1?.split('-') || [];
@@ -87,6 +87,7 @@ export async function testChangingTracingMetaTagsOnISRPage(
expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
]);
+ await expect(page.locator('meta[name="baggage"]')).toHaveCount(1);
const baggageMetaTagContent2 = await page.locator('meta[name="baggage"]').getAttribute('content');
const sentryTraceMetaTagContent2 = await page.locator('meta[name="sentry-trace"]').getAttribute('content');
const [htmlMetaTraceId2] = sentryTraceMetaTagContent2?.split('-') || [];
@@ -118,26 +119,36 @@ export async function testChangingTracingMetaTagsOnISRPage(
});
}
+async function getCacheOriginMetaTag(page: Page): Promise {
+ await expect(page.locator('meta[name="sentry-cache-origin"]')).toHaveCount(1);
+ expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
+ expect(await page.locator('meta[name="baggage"]').count()).toBe(0);
+ return page.locator('meta[name="sentry-cache-origin"]').getAttribute('content');
+}
+
+async function getRenderStart(page: Page): Promise {
+ await expect(page.locator('meta[name="sentry-render-start"]')).toHaveCount(1);
+ return Number(await page.locator('meta[name="sentry-render-start"]').getAttribute('content'));
+}
+
+const PAGE_SERVER_RENDERING_AGE = 'page.server_rendering.age';
+
+function expectedRenderAge(pageloadStart: number, renderStart: number): number {
+ return Math.max(0, Math.floor(pageloadStart - renderStart));
+}
+
/**
- * Tests that tracing meta-tags are excluded on cached pages (SWR, pre-rendered, etc.)
- * This utility handles the common pattern of:
- * 1. Making two requests to a cached page
- * 2. Verifying no tracing meta-tags are present
- * 3. Verifying traces are not distributed (each pageload starts its own trace)
- *
- * @param page - Playwright page object
- * @param routePath - The route path to test (e.g., '/rendering-modes/swr-cached-page')
- * @param expectedPageText - The text to verify is visible on the page (e.g., 'SWR Cached Page')
+ * Tests a page that a route rule caches at runtime. The cached HTML holds the `sentry-trace` value of
+ * the render in a `sentry-cache-origin` tag. Every pageload starts its own trace, is static, and links
+ * the render.
*/
-export async function testExcludeTracingMetaTagsOnCachedPage(
+export async function testCacheOriginOnRuntimeCachedPage(
page: Page,
routePath: string,
expectedPageText: string,
): Promise {
- // === 1. Request ===
+ // === 1. Request (renders and fills the cache) ===
const clientSpanPromise1 = waitForPageloadSegment(routePath);
-
- // Only the 1. request creates a server root span
const serverSpanPromise1 = waitForServerSegment(routePath);
const [_1, clientSpan1, serverSpan1] = await Promise.all([
@@ -146,13 +157,10 @@ export async function testExcludeTracingMetaTagsOnCachedPage(
serverSpanPromise1,
expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
]);
+ const cacheOrigin1 = await getCacheOriginMetaTag(page);
+ const renderStart1 = await getRenderStart(page);
- // Verify no baggage and sentry-trace meta-tags are present on first request
- expect(await page.locator('meta[name="baggage"]').count()).toBe(0);
- expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
-
- // === 2. Request ===
-
+ // === 2. Request (served from the cache) ===
const clientSpanPromise2 = waitForPageloadSegment(routePath);
const [_2, clientSpan2] = await Promise.all([
@@ -160,30 +168,97 @@ export async function testExcludeTracingMetaTagsOnCachedPage(
clientSpanPromise2,
expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
]);
+ const cacheOrigin2 = await getCacheOriginMetaTag(page);
+ const renderStart2 = await getRenderStart(page);
+
+ const [originTraceId, originSpanId, originSampled] = cacheOrigin1?.split('-') ?? [];
+ const cacheOriginLink = {
+ trace_id: serverSpan1.trace_id,
+ span_id: serverSpan1.span_id,
+ sampled: true,
+ attributes: { [SENTRY_LINK_TYPE]: { type: 'string', value: 'cache_origin' } },
+ };
+
+ await test.step('The cache origin tag holds the `http.server` root span of the 1. request', () => {
+ expect(originTraceId).toBe(serverSpan1.trace_id);
+ expect(originSpanId).toBe(serverSpan1.span_id);
+ expect(originSampled).toBe('1');
+ expect(cacheOrigin2).toBe(cacheOrigin1);
+ });
- const clientSpan1TraceId = clientSpan1.trace_id;
- const clientSpan2TraceId = clientSpan2.trace_id;
-
- const serverSpan1TraceId = serverSpan1.trace_id;
+ await test.step('Every pageload starts its own trace', () => {
+ expect(clientSpan1.parent_span_id).toBeUndefined();
+ expect(clientSpan2.parent_span_id).toBeUndefined();
+ expect(clientSpan1.trace_id).not.toBe(serverSpan1.trace_id);
+ expect(clientSpan2.trace_id).not.toBe(serverSpan1.trace_id);
+ expect(clientSpan1.trace_id).not.toBe(clientSpan2.trace_id);
+ });
- await test.step('No baggage and sentry-trace meta-tags are present on second request', async () => {
- expect(await page.locator('meta[name="baggage"]').count()).toBe(0);
- expect(await page.locator('meta[name="sentry-trace"]').count()).toBe(0);
+ await test.step('Every pageload is static and links the render', () => {
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan1.links).toEqual([cacheOriginLink]);
+ expect(clientSpan2.links).toEqual([cacheOriginLink]);
});
- await test.step('1. server root span and all client root spans are defined', () => {
- expect(serverSpan1TraceId).toBeDefined();
- expect(clientSpan1TraceId).toBeDefined();
- expect(clientSpan2TraceId).toBeDefined();
+ await test.step('Every pageload has the age of the render, which started with the 1. request', () => {
+ expect(renderStart1).toBe(Math.floor(serverSpan1.start_timestamp));
+ expect(renderStart2).toBe(renderStart1);
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan1.start_timestamp, renderStart1),
+ });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan2.start_timestamp, renderStart1),
+ });
});
+}
- await test.step('Trace is not distributed', () => {
- // Cannot create distributed trace as HTML Meta Tags are not added (caching leads to multiple usages of the same server trace id)
- expect(clientSpan1TraceId).not.toBe(clientSpan2TraceId);
- expect(clientSpan1TraceId).not.toBe(serverSpan1TraceId);
- expect(clientSpan2TraceId).not.toBe(serverSpan1TraceId);
- // Without meta tags the pageloads have no parent and start their own traces
- expect(clientSpan1.parent_span_id).toBeUndefined();
- expect(clientSpan2.parent_span_id).toBeUndefined();
+/**
+ * Tests a page that Nitro prerendered during the build. The SDK does not run in the build, so the
+ * `sentry-cache-origin` tag is empty: every pageload starts its own trace and is static, without a link.
+ */
+export async function testEmptyCacheOriginOnPrerenderedPage(
+ page: Page,
+ routePath: string,
+ expectedPageText: string,
+): Promise {
+ const clientSpanPromise1 = waitForPageloadSegment(routePath);
+ const [_1, clientSpan1] = await Promise.all([
+ page.goto(routePath),
+ clientSpanPromise1,
+ expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
+ ]);
+ const cacheOrigin1 = await getCacheOriginMetaTag(page);
+ const renderStart1 = await getRenderStart(page);
+
+ const clientSpanPromise2 = waitForPageloadSegment(routePath);
+ const [_2, clientSpan2] = await Promise.all([
+ page.goto(routePath),
+ clientSpanPromise2,
+ expect(page.getByText(expectedPageText, { exact: true })).toBeVisible(),
+ ]);
+ const cacheOrigin2 = await getCacheOriginMetaTag(page);
+ const renderStart2 = await getRenderStart(page);
+
+ expect(cacheOrigin1).toBe('');
+ expect(cacheOrigin2).toBe('');
+ expect(clientSpan1.parent_span_id).toBeUndefined();
+ expect(clientSpan2.parent_span_id).toBeUndefined();
+ expect(clientSpan1.trace_id).not.toBe(clientSpan2.trace_id);
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_TYPE]).toEqual({ type: 'string', value: 'static' });
+ expect(clientSpan1.links).toBeUndefined();
+ expect(clientSpan2.links).toBeUndefined();
+ // The build rendered the page, so the render start is the time of the build.
+ expect(renderStart2).toBe(renderStart1);
+ expect(clientSpan1.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan1.start_timestamp, renderStart1),
+ });
+ expect(clientSpan2.attributes?.[PAGE_SERVER_RENDERING_AGE]).toEqual({
+ type: 'integer',
+ value: expectedRenderAge(clientSpan2.start_timestamp, renderStart1),
});
}
diff --git a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/nuxt-5/tests/tunnel.test.ts
deleted file mode 100644
index 51e8a022c623..000000000000
--- a/dev-packages/e2e-tests/test-applications/nuxt-5/tests/tunnel.test.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { isServerSpanAt, watchForTunnelSpan } from '@sentry-internal/test-utils';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-test.beforeAll(async ({ request }) => {
- // `nuxt dev` opens the port before it's ready and answers 503 until then, and Playwright only waits for the port.
- await expect
- .poll(async () => (await request.get(`${process.env.E2E_TEST_BASE_PATH ?? ''}/`)).status(), { timeout: 30_000 })
- .not.toBe(503);
-});
-
-const BASE_PATH = process.env.E2E_TEST_BASE_PATH ?? '';
-const TUNNEL_PATH = new RegExp(`^${BASE_PATH}/[a-z0-9]{1,7}$`);
-
-test('answers the managed tunnel before the app auth middleware', async ({ page }) => {
- // The variant's auth middleware rejects every other POST.
- expect((await page.request.post(`${BASE_PATH}/api/anything`, { data: 'x' })).status()).toBe(401);
-
- const raceTunnelSpan = watchForTunnelSpan('nuxt-5', isServerSpanAt(TUNNEL_PATH));
- const tunnelResponsePromise = page.waitForResponse(
- response => response.request().method() === 'POST' && TUNNEL_PATH.test(new URL(response.url()).pathname),
- );
-
- await page.goto(`${BASE_PATH}/`);
-
- expect((await tunnelResponsePromise).status()).toBe(200);
- expect(
- await raceTunnelSpan(isServerSpanAt(`${BASE_PATH}/api/test-param/123`), () =>
- page.request.get(`${BASE_PATH}/api/test-param/123`),
- ),
- ).toBe('anchor');
-});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/package.json b/dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/package.json
index 16af3288c98c..0500b51516b1 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/package.json
+++ b/dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/package.json
@@ -15,7 +15,7 @@
},
"scripts": {
"build": "react-scripts build",
- "start": "run-p start:client start:server",
+ "start": "pnpm run --workspace-concurrency=Infinity \"/^start:(client|server)$/\"",
"start:client": "node server/app.js",
"start:server": "serve -s build",
"test": "playwright test",
@@ -45,7 +45,6 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "serve": "14.0.1",
- "npm-run-all2": "^6.2.0"
+ "serve": "14.0.1"
}
}
diff --git a/dev-packages/e2e-tests/test-applications/react-router-6/package.json b/dev-packages/e2e-tests/test-applications/react-router-6/package.json
index d61d433093d3..2101a3aa1a62 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-6/package.json
+++ b/dev-packages/e2e-tests/test-applications/react-router-6/package.json
@@ -15,7 +15,7 @@
},
"scripts": {
"build": "react-scripts build",
- "start": "run-p start:client start:server",
+ "start": "pnpm run --workspace-concurrency=Infinity \"/^start:(client|server)$/\"",
"start:client": "node server/app.js",
"start:server": "serve -s build",
"test": "playwright test",
@@ -45,8 +45,7 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
- "serve": "14.0.1",
- "npm-run-all2": "^6.2.0"
+ "serve": "14.0.1"
},
"sentryTest": {
"canaryVariants": [
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.client.tsx b/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.client.tsx
index 0215cdd728b9..005268b40ad0 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.client.tsx
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.client.tsx
@@ -6,8 +6,8 @@ import { HydratedRouter } from 'react-router/dom';
Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
// todo: get this from env
- dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://username@domain/123',
- tunnel: __E2E_TEST_TUNNEL__ ? true : `http://localhost:3031/`, // proxy server
+ dsn: 'https://username@domain/123',
+ tunnel: `http://localhost:3031/`, // proxy server
integrations: [Sentry.reactRouterTracingIntegration()],
tracesSampleRate: 1.0,
tracePropagationTargets: [/^\//],
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.server.cloudflare.tsx b/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.server.cloudflare.tsx
index 57bc9460c40c..3bf7701c6afe 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.server.cloudflare.tsx
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/entry.server.cloudflare.tsx
@@ -1,4 +1,3 @@
-import { captureException } from '@sentry/cloudflare';
import * as Sentry from '@sentry/react-router/cloudflare';
import { renderToReadableStream } from 'react-dom/server';
import { ServerRouter, type HandleErrorFunction } from 'react-router';
@@ -9,11 +8,6 @@ export default Sentry.createSentryHandleRequest({
getNonce: () => btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(16)))),
});
-export const handleError: HandleErrorFunction = (error, { request }) => {
- if (!request.signal.aborted) {
- captureException(error, { mechanism: { type: 'react-router', handled: false } });
- console.error(error);
- }
-};
+export const handleError: HandleErrorFunction = Sentry.createSentryHandleError({ logErrors: true });
export const instrumentations = [Sentry.createSentryServerInstrumentation()];
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/globals.d.ts b/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/globals.d.ts
deleted file mode 100644
index dc2e8cbcb587..000000000000
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/globals.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare const __E2E_TEST_TUNNEL__: boolean;
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/root.tsx b/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/root.tsx
index 3ae4b730b9e1..bc1b8f1236c0 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/root.tsx
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/app/root.tsx
@@ -2,20 +2,6 @@ import { Links, Meta, Outlet, Scripts, ScrollRestoration, isRouteErrorResponse }
import type { Route } from './+types/root';
import stylesheet from './app.css?url';
-// The tunnel variant checks that the managed tunnel answers before an auth middleware like this one. Other variants
-// get none, so their span assertions stay as they are.
-export const middleware: Route.MiddlewareFunction[] = __E2E_TEST_TUNNEL__
- ? [
- ({ request }, next) => {
- if (request.method === 'POST' && request.headers.get('x-auth') !== 'ok') {
- return new Response('blocked by user auth', { status: 401 });
- }
-
- return next();
- },
- ]
- : [];
-
export const links: Route.LinksFunction = () => [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/instrument.mjs b/dev-packages/e2e-tests/test-applications/react-router-8-framework/instrument.mjs
index 28a12bc0fe8d..c16240141b6d 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/instrument.mjs
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/instrument.mjs
@@ -1,12 +1,8 @@
import * as Sentry from '@sentry/react-router';
Sentry.init({
- dsn: process.env.E2E_TEST_TUNNEL ? 'http://public@localhost:3031/1337' : 'https://username@domain/123',
+ dsn: 'https://username@domain/123',
environment: 'qa', // dynamic sampling bias to keep transactions
tracesSampleRate: 1.0,
tunnel: `http://localhost:3031/`, // proxy server
- // The tunnel variants also accept another app's DSN, so the server serves more than one tunnel path.
- integrations: process.env.E2E_TEST_TUNNEL
- ? [Sentry.serveTunnelIntegration({ allowedDsns: ['http://other@localhost:3031/1338'] })]
- : [],
});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/package.json b/dev-packages/e2e-tests/test-applications/react-router-8-framework/package.json
index 282a31c2fa37..ed1be9b809b7 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/package.json
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/package.json
@@ -44,10 +44,7 @@
"test:build": "pnpm install && pnpm build",
"test:assert": "pnpm test:ts && pnpm test:playwright",
"test:ts": "pnpm typecheck",
- "test:playwright": "playwright test",
- "test:build:tunnel-basepath": "pnpm install && E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm build",
- "test:assert:tunnel-basepath": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm test:playwright tunnel",
- "test:assert:tunnel-basepath-dev": "TEST_ENV=development E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app pnpm test:playwright tunnel"
+ "test:playwright": "playwright test"
},
"eslintConfig": {
"extends": [
@@ -85,22 +82,6 @@
{
"runtime": "cloudflare",
"label": "react-router-8-framework (cloudflare)"
- },
- {
- "build-command": "pnpm test:build:tunnel-basepath",
- "assert-command": "pnpm test:assert:tunnel-basepath",
- "label": "react-router-8-framework (tunnel-basepath)"
- },
- {
- "runtime": "cloudflare",
- "build-command": "pnpm test:build:tunnel-basepath",
- "assert-command": "pnpm test:assert:tunnel-basepath",
- "label": "react-router-8-framework (tunnel-basepath-cloudflare)"
- },
- {
- "label": "react-router-8-framework (tunnel-basepath-dev)",
- "build-command": "pnpm install",
- "assert-command": "pnpm test:assert:tunnel-basepath-dev"
}
]
}
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/react-router.config.ts b/dev-packages/e2e-tests/test-applications/react-router-8-framework/react-router.config.ts
index a74ae0b46048..bb1f96469dd2 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/react-router.config.ts
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/react-router.config.ts
@@ -2,7 +2,5 @@ import type { Config } from '@react-router/dev/config';
export default {
ssr: true,
- // The base-path variant serves the app, and so the tunnel, under `/app`.
- ...(process.env.E2E_TEST_BASE_PATH && { basename: `${process.env.E2E_TEST_BASE_PATH}/` }),
prerender: ['/performance/static'],
} satisfies Config;
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/react-router-8-framework/tests/tunnel.test.ts
deleted file mode 100644
index 916ea878d170..000000000000
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/tests/tunnel.test.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { isServerSpanAt, watchForTunnelSpan } from '@sentry-internal/test-utils';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-const APP_NAME = 'react-router-8-framework';
-const BASE_PATH = process.env.E2E_TEST_BASE_PATH ?? '';
-const TUNNEL_PATH = new RegExp(`^${BASE_PATH}/[a-z0-9]{1,7}$`);
-
-test('answers the managed tunnel before the root middleware', async ({ page }) => {
- // The variant's root middleware rejects every other POST.
- expect((await page.request.post(`${BASE_PATH}/`, { data: 'x' })).status()).toBe(401);
-
- const raceTunnelSpan = watchForTunnelSpan(APP_NAME, isServerSpanAt(TUNNEL_PATH));
- const tunnelResponsePromise = page.waitForResponse(
- response => response.request().method() === 'POST' && TUNNEL_PATH.test(new URL(response.url()).pathname),
- );
-
- await page.goto(`${BASE_PATH}/`);
-
- expect((await tunnelResponsePromise).status()).toBe(200);
- expect(
- await raceTunnelSpan(isServerSpanAt(`${BASE_PATH}/performance`), () =>
- page.request.get(`${BASE_PATH}/performance`),
- ),
- ).toBe('anchor');
-});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.cloudflare.config.ts b/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.cloudflare.config.ts
index 032293400dbf..002bb3a77fbe 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.cloudflare.config.ts
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.cloudflare.config.ts
@@ -5,9 +5,6 @@ import { sentryReactRouter } from '@sentry/react-router/vite';
import { defineConfig } from 'vite';
export default defineConfig(async config => ({
- define: {
- __E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
- },
plugins: [
cloudflare({ viteEnvironment: { name: 'ssr' } }),
reactRouter(),
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.config.ts b/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.config.ts
index 3663eb2a74b5..0fe4cdde8c7a 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.config.ts
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/vite.config.ts
@@ -4,9 +4,6 @@ import { defineConfig } from 'vite';
export default defineConfig(config => {
return {
- define: {
- __E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
- },
plugins: [reactRouter(), sentryReactRouter({ sourcemaps: { disable: true } }, config)],
};
});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-framework/workers/instrument.server.ts b/dev-packages/e2e-tests/test-applications/react-router-8-framework/workers/instrument.server.ts
index ac69c92c81b6..be998ae29a13 100644
--- a/dev-packages/e2e-tests/test-applications/react-router-8-framework/workers/instrument.server.ts
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-framework/workers/instrument.server.ts
@@ -1,11 +1,8 @@
-import { defineCloudflareOptions, serveTunnelIntegration } from '@sentry/cloudflare';
-
-declare const __E2E_TEST_TUNNEL__: boolean;
+import { defineCloudflareOptions } from '@sentry/cloudflare';
export default defineCloudflareOptions({
- dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://username@domain/123',
+ dsn: 'https://username@domain/123',
environment: 'qa', // dynamic sampling bias to keep transactions
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
- integrations: __E2E_TEST_TUNNEL__ ? [serveTunnelIntegration()] : [],
});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.client.tsx b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.client.tsx
new file mode 100644
index 000000000000..bb1fdf29506d
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.client.tsx
@@ -0,0 +1,16 @@
+import * as Sentry from '@sentry/react-router';
+import { startTransition } from 'react';
+import { hydrateRoot } from 'react-dom/client';
+import { HydratedRouter } from 'react-router/dom';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ // The SDK serves it under the app's `basename`.
+ tunnel: true,
+ integrations: [Sentry.reactRouterTracingIntegration()],
+ tracesSampleRate: 1,
+});
+
+startTransition(() => {
+ hydrateRoot(document, );
+});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.server.cloudflare.tsx b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.server.cloudflare.tsx
new file mode 100644
index 000000000000..225888993067
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.server.cloudflare.tsx
@@ -0,0 +1,10 @@
+import { captureException } from '@sentry/cloudflare';
+import * as Sentry from '@sentry/react-router/cloudflare';
+import { renderToReadableStream } from 'react-dom/server';
+import { type HandleErrorFunction, ServerRouter } from 'react-router';
+
+export default Sentry.createSentryHandleRequest({ renderToReadableStream, ServerRouter });
+
+export const handleError: HandleErrorFunction = error => {
+ captureException(error, { mechanism: { type: 'react-router', handled: false } });
+};
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.server.tsx b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.server.tsx
new file mode 100644
index 000000000000..58e98143085a
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/entry.server.tsx
@@ -0,0 +1,12 @@
+import { createReadableStreamFromReadable } from '@react-router/node';
+import * as Sentry from '@sentry/react-router';
+import { renderToPipeableStream } from 'react-dom/server';
+import { ServerRouter } from 'react-router';
+
+export default Sentry.createSentryHandleRequest({
+ ServerRouter,
+ renderToPipeableStream,
+ createReadableStreamFromReadable,
+});
+
+export const handleError = Sentry.createSentryHandleError({ logErrors: false });
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/root.tsx b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/root.tsx
new file mode 100644
index 000000000000..fe3e665b818e
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/root.tsx
@@ -0,0 +1,17 @@
+import { Outlet, Scripts } from 'react-router';
+import type { Route } from './+types/root';
+
+export const middleware: Route.MiddlewareFunction[] = [
+ ({ request }, next) => (request.method === 'POST' ? new Response('blocked by user auth', { status: 401 }) : next()),
+];
+
+export default function App() {
+ return (
+
+
+
+
+
+
+ );
+}
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes.ts
new file mode 100644
index 000000000000..ef867ca0015a
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes.ts
@@ -0,0 +1,3 @@
+import { type RouteConfig, route } from '@react-router/dev/routes';
+
+export default [route('api/anchor', 'routes/anchor.ts'), route('api/error', 'routes/error.ts')] satisfies RouteConfig;
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes/anchor.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes/anchor.ts
new file mode 100644
index 000000000000..8ff19a6f8c0c
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes/anchor.ts
@@ -0,0 +1,3 @@
+export function loader() {
+ return Response.json({ ok: true });
+}
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes/error.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes/error.ts
new file mode 100644
index 000000000000..4b849faad63c
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/app/routes/error.ts
@@ -0,0 +1,3 @@
+export function loader() {
+ throw new Error('Tunnel test error');
+}
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/instrument.mjs b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/instrument.mjs
new file mode 100644
index 000000000000..c8d6d9912ca1
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/instrument.mjs
@@ -0,0 +1,8 @@
+import * as Sentry from '@sentry/react-router';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ // A second DSN makes the server serve more than one tunnel path.
+ integrations: [Sentry.serveTunnelIntegration({ allowedDsns: ['http://other@localhost:3031/1338'] })],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/package.json b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/package.json
new file mode 100644
index 000000000000..80e6ae434a99
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "react-router-8-tunnel",
+ "version": "1.0.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "build": "react-router build",
+ "dev": "NODE_OPTIONS='--import ./instrument.mjs' react-router dev --port 3030",
+ "start": "PORT=3030 NODE_ENV=production NODE_OPTIONS='--import ./instrument.mjs' react-router-serve ./build/server/index.js",
+ "start:cloudflare": "wrangler dev --config ./build/server/wrangler.json --port 3030",
+ "clean": "npx rimraf node_modules pnpm-lock.yaml build",
+ "test:build": "pnpm install && pnpm build",
+ "test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
+ },
+ "dependencies": {
+ "@react-router/node": "^8.0.0",
+ "@react-router/serve": "^8.0.0",
+ "@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
+ "@sentry/react-router": "file:../../packed/sentry-react-router-packed.tgz",
+ "react": "^19.2.7",
+ "react-dom": "^19.2.7",
+ "react-router": "^8.0.0"
+ },
+ "devDependencies": {
+ "@cloudflare/vite-plugin": "^1.35.0",
+ "@playwright/test": "1.64.1",
+ "@react-router/dev": "^8.0.0",
+ "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
+ "vite": "^7.3.2",
+ "wrangler": "^4.120.0"
+ },
+ "sentryTest": {
+ "variants": [
+ {
+ "runtime": "cloudflare",
+ "assert-command": "TEST_ENV=production pnpm exec playwright test",
+ "label": "react-router-8-tunnel (cloudflare)"
+ }
+ ]
+ }
+}
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/playwright.config.mjs
new file mode 100644
index 000000000000..83d0e5bfd1b4
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/playwright.config.mjs
@@ -0,0 +1,10 @@
+import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils';
+
+export default getPlaywrightConfig({
+ startCommand:
+ process.env.TEST_ENV === 'development'
+ ? 'pnpm dev'
+ : getRuntime() === 'cloudflare'
+ ? 'pnpm start:cloudflare'
+ : 'pnpm start',
+});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/pnpm-workspace.yaml
new file mode 100644
index 000000000000..fd29a82085e0
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/pnpm-workspace.yaml
@@ -0,0 +1,4 @@
+allowBuilds:
+ esbuild: true
+ workerd: true
+minimumReleaseAge: 0
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/react-router.config.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/react-router.config.ts
new file mode 100644
index 000000000000..d7a2616ea3b4
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/react-router.config.ts
@@ -0,0 +1,6 @@
+import type { Config } from '@react-router/dev/config';
+
+export default {
+ ssr: true,
+ basename: '/app/',
+} satisfies Config;
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/start-event-proxy.mjs
new file mode 100644
index 000000000000..90f6cb9ea760
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/start-event-proxy.mjs
@@ -0,0 +1,6 @@
+import { startEventProxyServer } from '@sentry-internal/test-utils';
+
+startEventProxyServer({
+ port: 3031,
+ proxyServerName: 'react-router-8-tunnel',
+});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/tests/tunnel.test.ts
new file mode 100644
index 000000000000..86dfae02b429
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/tests/tunnel.test.ts
@@ -0,0 +1,3 @@
+import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';
+
+runManagedTunnelSuite({ appName: 'react-router-8-tunnel', basePath: '/app' });
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/vite.cloudflare.config.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/vite.cloudflare.config.ts
new file mode 100644
index 000000000000..be15509be49b
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/vite.cloudflare.config.ts
@@ -0,0 +1,14 @@
+import { cloudflare } from '@cloudflare/vite-plugin';
+import { reactRouter } from '@react-router/dev/vite';
+import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
+import { sentryReactRouter } from '@sentry/react-router/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig(async config => ({
+ plugins: [
+ cloudflare({ viteEnvironment: { name: 'ssr' } }),
+ reactRouter(),
+ sentryCloudflareVitePlugin(),
+ ...((await sentryReactRouter({ sourcemaps: { disable: true } }, config)) as any[]),
+ ],
+}));
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/vite.config.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/vite.config.ts
new file mode 100644
index 000000000000..a484c7b96f8a
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/vite.config.ts
@@ -0,0 +1,7 @@
+import { reactRouter } from '@react-router/dev/vite';
+import { sentryReactRouter } from '@sentry/react-router/vite';
+import { defineConfig } from 'vite';
+
+export default defineConfig(config => ({
+ plugins: [reactRouter(), sentryReactRouter({ sourcemaps: { disable: true } }, config)],
+}));
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/workers/app.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/workers/app.ts
new file mode 100644
index 000000000000..e14713f82cde
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/workers/app.ts
@@ -0,0 +1,9 @@
+import { createRequestHandler } from 'react-router';
+
+const requestHandler = createRequestHandler(() => import('virtual:react-router/server-build'), import.meta.env.MODE);
+
+export default {
+ async fetch(request: Request) {
+ return requestHandler(request);
+ },
+};
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/workers/instrument.server.ts b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/workers/instrument.server.ts
new file mode 100644
index 000000000000..660fe94f5489
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/workers/instrument.server.ts
@@ -0,0 +1,7 @@
+import { defineCloudflareOptions, serveTunnelIntegration } from '@sentry/cloudflare';
+
+export default defineCloudflareOptions({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [serveTunnelIntegration()],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/wrangler.jsonc b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/wrangler.jsonc
new file mode 100644
index 000000000000..a99997aa9fc1
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/react-router-8-tunnel/wrangler.jsonc
@@ -0,0 +1,10 @@
+{
+ "$schema": "node_modules/wrangler/config-schema.json",
+ "name": "react-router-8-tunnel",
+ "compatibility_date": "2026-06-29",
+ "compatibility_flags": ["nodejs_compat"],
+ "main": "./workers/app.ts",
+ "assets": {
+ "directory": "./build/client",
+ },
+}
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/app/entry.ts b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/app/entry.ts
new file mode 100644
index 000000000000..5b1453150621
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/app/entry.ts
@@ -0,0 +1,7 @@
+import * as Sentry from '@sentry/remix/v3/client';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ tunnel: true,
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/package.json b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/package.json
new file mode 100644
index 000000000000..ba521c0759c1
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "remix-v3-tunnel",
+ "version": "1.0.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "start": "NODE_ENV=production node --import @sentry/remix/v3/node server.ts",
+ "clean": "npx rimraf node_modules pnpm-lock.yaml",
+ "test:build": "pnpm install",
+ "test:assert": "playwright test && E2E_TEST_PLAIN_SERVER=1 playwright test"
+ },
+ "dependencies": {
+ "@sentry/remix": "file:../../packed/sentry-remix-packed.tgz",
+ "remix": "3.1.0"
+ },
+ "devDependencies": {
+ "@playwright/test": "1.64.1",
+ "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
+ }
+}
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/playwright.config.mjs
new file mode 100644
index 000000000000..3ecc1c983751
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/playwright.config.mjs
@@ -0,0 +1,3 @@
+import { getPlaywrightConfig } from '@sentry-internal/test-utils';
+
+export default getPlaywrightConfig({ startCommand: 'pnpm start' });
diff --git a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/pnpm-workspace.yaml
similarity index 62%
rename from dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/pnpm-workspace.yaml
rename to dev-packages/e2e-tests/test-applications/remix-v3-tunnel/pnpm-workspace.yaml
index 428f42f5ee7b..3cdf2ff22992 100644
--- a/dev-packages/e2e-tests/test-applications/node-otel-sdk-node-v3/pnpm-workspace.yaml
+++ b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/pnpm-workspace.yaml
@@ -1,3 +1,3 @@
allowBuilds:
- protobufjs: false
+ esbuild: true
minimumReleaseAge: 0
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/server.ts b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/server.ts
new file mode 100644
index 000000000000..5188a743ce2f
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/server.ts
@@ -0,0 +1,58 @@
+import * as Sentry from '@sentry/remix/v3';
+import * as http from 'node:http';
+import { Readable } from 'node:stream';
+import { createAssetServer } from 'remix/assets';
+import { createRequestListener } from 'remix/node-fetch-server';
+import { createRouter } from 'remix/router';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [Sentry.serveTunnelIntegration()],
+ tracesSampleRate: 1,
+});
+
+const assets = createAssetServer({
+ basePath: '/assets',
+ allowFiles: ['app/entry.ts'],
+ allowPackages: ['@sentry/remix'],
+ watch: false,
+});
+const entry = await assets.getScriptEntry('app/entry.ts');
+const page = ``;
+
+const router = createRouter();
+router.get('/', () => new Response(page, { headers: { 'Content-Type': 'text/html' } }));
+router.get(
+ '/assets/*path',
+ async ({ request }) => (await assets.fetch(request)) ?? new Response(null, { status: 404 }),
+);
+router.get('/api/anchor', () => Response.json({ ok: true }));
+router.get('/api/error', () => {
+ throw new Error('Tunnel test error');
+});
+
+// Rejects every POST ahead of the router, so a tunnel request only gets its 200 when the SDK answers it first.
+function handle(request: Request): Promise | Response {
+ return request.method === 'POST' ? new Response('blocked by user auth', { status: 401 }) : router.fetch(request);
+}
+
+// A bare `node:http` adapter, for apps that serve the router without `createRequestListener`.
+const plainListener: http.RequestListener = async (req, res) => {
+ const hasBody = req.method !== 'GET' && req.method !== 'HEAD';
+ const request = new Request(`http://${req.headers.host}${req.url}`, {
+ method: req.method,
+ headers: req.headers as HeadersInit,
+ body: hasBody ? (Readable.toWeb(req) as ReadableStream) : undefined,
+ duplex: 'half',
+ } as RequestInit);
+
+ try {
+ const response = await handle(request);
+ res.writeHead(response.status, Object.fromEntries(response.headers));
+ res.end(Buffer.from(await response.arrayBuffer()));
+ } catch {
+ res.writeHead(500).end();
+ }
+};
+
+http.createServer(process.env.E2E_TEST_PLAIN_SERVER ? plainListener : createRequestListener(handle)).listen(3030);
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/start-event-proxy.mjs
new file mode 100644
index 000000000000..f53bce0d01b6
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/start-event-proxy.mjs
@@ -0,0 +1,6 @@
+import { startEventProxyServer } from '@sentry-internal/test-utils';
+
+startEventProxyServer({
+ port: 3031,
+ proxyServerName: 'remix-v3-tunnel',
+});
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/tests/tunnel.test.ts
new file mode 100644
index 000000000000..58b1468d2b64
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/remix-v3-tunnel/tests/tunnel.test.ts
@@ -0,0 +1,3 @@
+import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';
+
+runManagedTunnelSuite({ appName: 'remix-v3-tunnel', basePath: '' });
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/public/entry.ts b/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/public/entry.ts
index 89bdd61f5491..bbeee228783a 100644
--- a/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/public/entry.ts
+++ b/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/public/entry.ts
@@ -9,7 +9,7 @@ declare const process: { env: Record };
Sentry.init({
dsn: process.env.E2E_TEST_DSN,
- tunnel: process.env.E2E_TEST_TUNNEL ? true : 'http://localhost:3061/',
+ tunnel: 'http://localhost:3061/',
tracesSampleRate: 1.0,
});
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/app/assets.ts b/dev-packages/e2e-tests/test-applications/remix-v3/app/assets.ts
index 4bfe6672caf4..f3ab7fcf4c4d 100644
--- a/dev-packages/e2e-tests/test-applications/remix-v3/app/assets.ts
+++ b/dev-packages/e2e-tests/test-applications/remix-v3/app/assets.ts
@@ -6,16 +6,12 @@ export const assets = createAssetServer({
allowFiles: ['app/routes.ts', 'app/**/public/**'],
allowPackages: ['remix', '@sentry/remix'],
minify: true,
- scripts: {
- define: { 'process.env.E2E_TEST_DSN': JSON.stringify(process.env.E2E_TEST_DSN) },
- },
watch: false,
scripts: {
// No bundler means no build time env inlining, so `define` is the only way to get configuration
// into a browser module. The asset server substitutes these when it compiles.
define: {
'process.env.E2E_TEST_DSN': JSON.stringify(process.env.E2E_TEST_DSN),
- 'process.env.E2E_TEST_TUNNEL': JSON.stringify(process.env.E2E_TEST_TUNNEL ?? ''),
},
},
});
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/app/router.ts b/dev-packages/e2e-tests/test-applications/remix-v3/app/router.ts
index 2102a5768372..03724dd7ea27 100644
--- a/dev-packages/e2e-tests/test-applications/remix-v3/app/router.ts
+++ b/dev-packages/e2e-tests/test-applications/remix-v3/app/router.ts
@@ -14,21 +14,8 @@ declare module 'remix/router' {
}
}
-// The tunnel variant checks that the managed tunnel answers before an auth middleware like this one.
-function authMiddleware(context: { request: Request }, next: () => Promise): Promise | Response {
- if (
- process.env.E2E_TEST_TUNNEL &&
- context.request.method === 'POST' &&
- context.request.headers.get('x-auth') !== 'ok'
- ) {
- return new Response('blocked by user auth', { status: 401 });
- }
-
- return next();
-}
-
export const router = createRouter({
- middleware: [authMiddleware, renderMiddleware],
+ middleware: [renderMiddleware],
});
router.map(routes, controller);
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/package.json b/dev-packages/e2e-tests/test-applications/remix-v3/package.json
index f24799a42e64..f82e44a803f3 100644
--- a/dev-packages/e2e-tests/test-applications/remix-v3/package.json
+++ b/dev-packages/e2e-tests/test-applications/remix-v3/package.json
@@ -8,9 +8,7 @@
"test": "playwright test",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install",
- "test:assert": "pnpm test",
- "test:assert:tunnel": "E2E_TEST_TUNNEL=1 E2E_TEST_DSN=http://public@localhost:3061/1337 playwright test tunnel",
- "test:assert:tunnel-plain-server": "E2E_TEST_PLAIN_SERVER=1 pnpm test:assert:tunnel"
+ "test:assert": "pnpm test"
},
"dependencies": {
"@sentry/remix": "file:../../packed/sentry-remix-packed.tgz",
@@ -21,19 +19,5 @@
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"@types/node": "^24.6.0",
"typescript": "~5.9.0"
- },
- "sentryTest": {
- "variants": [
- {
- "build-command": "pnpm test:build",
- "assert-command": "pnpm test:assert:tunnel",
- "label": "remix-v3 (tunnel)"
- },
- {
- "build-command": "pnpm test:build",
- "assert-command": "pnpm test:assert:tunnel-plain-server",
- "label": "remix-v3 (tunnel, plain server)"
- }
- ]
}
}
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/server.ts b/dev-packages/e2e-tests/test-applications/remix-v3/server.ts
index d2b2bbf7a0e6..0f7d21ec2f0d 100644
--- a/dev-packages/e2e-tests/test-applications/remix-v3/server.ts
+++ b/dev-packages/e2e-tests/test-applications/remix-v3/server.ts
@@ -1,6 +1,5 @@
import * as Sentry from '@sentry/remix/v3';
import * as http from 'node:http';
-import { Readable } from 'node:stream';
import { createRequestListener } from 'remix/node-fetch-server';
import { router } from './app/router.ts';
@@ -8,59 +7,21 @@ import { router } from './app/router.ts';
Sentry.init({
dsn: process.env.E2E_TEST_DSN,
tunnel: 'http://localhost:3061/',
- integrations: process.env.E2E_TEST_TUNNEL ? [Sentry.serveTunnelIntegration()] : [],
tracesSampleRate: 1.0,
});
const port = process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 3060;
-// The plain server variant serves the router without `createRequestListener`, so only the router middleware can
-// answer the tunnel there.
-const plainServer = !!process.env.E2E_TEST_PLAIN_SERVER;
-
function handle(request: Request): Response | Promise {
// Handled outside the router on purpose: the only hook that can see this is the listener's
// `onError`, which is the case the router middleware cannot cover.
if (new URL(request.url).pathname === '/plain-throw') {
throw new Error('Plain handler failed');
}
- // The tunnel variant checks that the managed tunnel answers before code the app runs in front of its router. With
- // the plain server nothing runs ahead of this, so it would block the tunnel there.
- if (
- process.env.E2E_TEST_TUNNEL &&
- !plainServer &&
- request.method === 'POST' &&
- request.headers.get('x-app-auth') !== 'ok'
- ) {
- return new Response('blocked by the app before its router', { status: 403 });
- }
return router.fetch(request);
}
-/**
- * A bare `node:http` adapter for the fetch handler.
- */
-function toNodeListener(handler: (request: Request) => Response | Promise): http.RequestListener {
- return async (req, res) => {
- const hasBody = req.method !== 'GET' && req.method !== 'HEAD';
- const request = new Request(`http://localhost:${port}${req.url}`, {
- method: req.method,
- headers: req.headers as HeadersInit,
- body: hasBody ? (Readable.toWeb(req) as ReadableStream) : undefined,
- duplex: 'half',
- } as RequestInit);
-
- try {
- const response = await handler(request);
- res.writeHead(response.status, Object.fromEntries(response.headers));
- res.end(Buffer.from(await response.arrayBuffer()));
- } catch {
- res.writeHead(500).end();
- }
- };
-}
-
-const server = http.createServer(plainServer ? toNodeListener(handle) : createRequestListener(handle));
+const server = http.createServer(createRequestListener(handle));
server.listen(port, () => {
console.log(`Server listening on http://localhost:${port}`);
diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/tests/tunnel.test.ts b/dev-packages/e2e-tests/test-applications/remix-v3/tests/tunnel.test.ts
deleted file mode 100644
index 6254b884e69a..000000000000
--- a/dev-packages/e2e-tests/test-applications/remix-v3/tests/tunnel.test.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { expect, test } from '@playwright/test';
-import { isServerSpanAt, watchForTunnelSpan } from '@sentry-internal/test-utils';
-
-test.skip(!process.env.E2E_TEST_TUNNEL, 'Only runs in the tunnel variant');
-
-const TUNNEL_PATH = /^\/[a-z0-9]{1,7}$/;
-
-test('the app handler rejects other POSTs before the router', async ({ page }) => {
- // The plain server has nothing ahead of the router that could answer the tunnel.
- test.skip(!!process.env.E2E_TEST_PLAIN_SERVER, 'Only the request listener variant has a handler ahead of the router');
-
- expect((await page.request.post('/anything', { data: 'x' })).status()).toBe(403);
-});
-
-test('answers the managed tunnel before the app handler, route matching and the app middleware', async ({ page }) => {
- // The app's auth middleware rejects the POSTs that get past its handler.
- expect((await page.request.post('/anything', { data: 'x', headers: { 'x-app-auth': 'ok' } })).status()).toBe(401);
-
- const raceTunnelSpan = watchForTunnelSpan('remix-v3', isServerSpanAt(TUNNEL_PATH));
- const tunnelResponsePromise = page.waitForResponse(
- response => response.request().method() === 'POST' && TUNNEL_PATH.test(new URL(response.url()).pathname),
- );
-
- await page.goto('/');
-
- expect((await tunnelResponsePromise).status()).toBe(200);
- expect(await raceTunnelSpan(isServerSpanAt('/api/items/1'), () => page.request.get('/api/items/1'))).toBe('anchor');
-});
diff --git a/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/app.config.ts b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/app.config.ts
new file mode 100644
index 000000000000..2063280f4b64
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/app.config.ts
@@ -0,0 +1,10 @@
+import { withSentry } from '@sentry/solidstart/vite';
+import { defineConfig } from '@solidjs/start/config';
+
+export default defineConfig(
+ withSentry(
+ { middleware: './src/middleware.ts', server: { baseURL: '/app/' } },
+ // `vinxi dev` builds nothing, so the dev server loads this same file with `--import`.
+ { instrumentation: './instrument.server.mjs' },
+ ),
+);
diff --git a/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/instrument.server.mjs b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/instrument.server.mjs
new file mode 100644
index 000000000000..0f2a3b373559
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/instrument.server.mjs
@@ -0,0 +1,7 @@
+import * as Sentry from '@sentry/solidstart';
+
+Sentry.init({
+ dsn: 'http://public@localhost:3031/1337',
+ integrations: [Sentry.serveTunnelIntegration()],
+ tracesSampleRate: 1,
+});
diff --git a/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/package.json b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/package.json
new file mode 100644
index 000000000000..fd243e5a2aae
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "solidstart-1-tunnel",
+ "version": "1.0.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "build": "vinxi build",
+ "start": "HOST=localhost PORT=3030 node --import ./.output/server/instrument.server.mjs .output/server/index.mjs",
+ "clean": "npx rimraf node_modules pnpm-lock.yaml .vinxi .output",
+ "test:build": "pnpm install && pnpm build",
+ "test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
+ },
+ "dependencies": {
+ "@sentry/solidstart": "latest || *"
+ },
+ "devDependencies": {
+ "@playwright/test": "1.64.1",
+ "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
+ "@solidjs/start": "^1.0.2",
+ "solid-js": "1.9.5",
+ "vinxi": "^0.5.11",
+ "vite": "^6.4.4"
+ }
+}
diff --git a/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/playwright.config.mjs
new file mode 100644
index 000000000000..b99c2fa6587c
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/playwright.config.mjs
@@ -0,0 +1,9 @@
+import { getPlaywrightConfig } from '@sentry-internal/test-utils';
+
+export default getPlaywrightConfig({
+ // `vinxi dev` ignores PORT.
+ startCommand:
+ process.env.TEST_ENV === 'development'
+ ? `NODE_OPTIONS='--import ./instrument.server.mjs' pnpm exec vinxi dev --port 3030`
+ : `pnpm start`,
+});
diff --git a/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/pnpm-workspace.yaml
new file mode 100644
index 000000000000..9355b28e8d0e
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/pnpm-workspace.yaml
@@ -0,0 +1,4 @@
+allowBuilds:
+ '@parcel/watcher': true
+ esbuild: true
+minimumReleaseAge: 0
diff --git a/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/src/app.tsx b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/src/app.tsx
new file mode 100644
index 000000000000..100ef5c33935
--- /dev/null
+++ b/dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/src/app.tsx
@@ -0,0 +1,3 @@
+export default function App() {
+ return