File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
dev-packages/e2e-tests/test-applications/nitro-3 Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 55 "type" : " module" ,
66 "scripts" : {
77 "build" : " nitro build" ,
8- "start" : " PORT=3030 NODE_OPTIONS='--import ./instrument.mjs' npx srvx --prod .output/" ,
8+ "start" : " PORT=3030 NODE_OPTIONS='--import ./instrument.mjs' srvx --prod .output/" ,
99 "clean" : " npx rimraf node_modules pnpm-lock.yaml .output" ,
1010 "test" : " playwright test" ,
1111 "test:build" : " pnpm install && pnpm build" ,
1717 "devDependencies" : {
1818 "@playwright/test" : " ~1.56.0" ,
1919 "@sentry-internal/test-utils" : " link:../../../test-utils" ,
20+ "@sentry/core" : " latest || *" ,
2021 "nitro" : " https://pkg.pr.new/nitrojs/nitro@4001" ,
21- "rolldown" : " latest"
22+ "rolldown" : " latest" ,
23+ "srvx" : " ^0.11.2"
2224 },
2325 "volta" : {
2426 "extends" : " ../../package.json"
Original file line number Diff line number Diff line change 1+ import { getDefaultIsolationScope , setTag } from '@sentry/core' ;
2+ import { defineHandler } from 'nitro/h3' ;
3+
4+ export default defineHandler ( ( ) => {
5+ setTag ( 'my-isolated-tag' , true ) ;
6+ // Check if the tag leaked into the default (global) isolation scope
7+ setTag ( 'my-global-scope-isolated-tag' , getDefaultIsolationScope ( ) . getScopeData ( ) . tags [ 'my-isolated-tag' ] ) ;
8+
9+ throw new Error ( 'Isolation test error' ) ;
10+ } ) ;
Original file line number Diff line number Diff line change 1+ import { expect , test } from '@playwright/test' ;
2+ import { waitForError , waitForTransaction } from '@sentry-internal/test-utils' ;
3+
4+ test ( 'Isolation scope prevents tag leaking between requests' , async ( { request } ) => {
5+ const transactionEventPromise = waitForTransaction ( 'nitro-3' , event => {
6+ return event ?. transaction === 'GET /test-isolation/1' ;
7+ } ) ;
8+
9+ const errorPromise = waitForError ( 'nitro-3' , event => {
10+ return ! event . type && event . exception ?. values ?. some ( v => v . value === 'Isolation test error' ) ;
11+ } ) ;
12+
13+ await request . get ( '/test-isolation/1' ) . catch ( ( ) => {
14+ // noop - route throws
15+ } ) ;
16+
17+ const transactionEvent = await transactionEventPromise ;
18+ const error = await errorPromise ;
19+
20+ // Assert that isolation scope works properly
21+ expect ( error . tags ?. [ 'my-isolated-tag' ] ) . toBe ( true ) ;
22+ expect ( error . tags ?. [ 'my-global-scope-isolated-tag' ] ) . not . toBeDefined ( ) ;
23+ expect ( transactionEvent . tags ?. [ 'my-isolated-tag' ] ) . toBe ( true ) ;
24+ expect ( transactionEvent . tags ?. [ 'my-global-scope-isolated-tag' ] ) . not . toBeDefined ( ) ;
25+ } ) ;
You can’t perform that action at this time.
0 commit comments