@@ -94,28 +94,39 @@ describe('Server init()', () => {
9494 expect ( second ) . toBe ( first ) ;
9595 } ) ;
9696
97- it ( 'skips init and sets the `turbopack` tag on Cloudflare Workers in a request of `withSentry` from `@sentry/cloudflare`' , ( ) => {
97+ it ( 'skips init on Cloudflare Workers in a request of `withSentry` from `@sentry/cloudflare`' , ( ) => {
9898 vi . stubGlobal ( 'navigator' , { userAgent : 'Cloudflare-Workers' } ) ;
9999 setAsyncLocalStorageAsyncContextStrategy ( ) ;
100- ( process as { turbopack ?: boolean } ) . turbopack = true ;
101100
102101 withIsolationScope ( ( ) => init ( { } ) ) ;
103102
104103 expect ( nodeInit ) . not . toHaveBeenCalled ( ) ;
105- expect ( getGlobalScope ( ) . getScopeData ( ) . tags . turbopack ) . toBe ( true ) ;
106104 } ) ;
107105
108- it ( 'adds its event processors to the global scope on Cloudflare Workers in a request of `withSentry` from `@sentry/cloudflare`' , ( ) => {
106+ it ( 'sets the `turbopack` tag on Cloudflare Workers in a request of `withSentry` from `@sentry/cloudflare`' , ( ) => {
109107 vi . stubGlobal ( 'navigator' , { userAgent : 'Cloudflare-Workers' } ) ;
110108 setAsyncLocalStorageAsyncContextStrategy ( ) ;
109+ ( process as { turbopack ?: boolean } ) . turbopack = true ;
111110
112111 withIsolationScope ( ( ) => init ( { } ) ) ;
113112
113+ expect ( getGlobalScope ( ) . getScopeData ( ) . tags . turbopack ) . toBe ( true ) ;
114+ } ) ;
115+
116+ it ( 'adds its event processors to the global scope once on Cloudflare Workers in a request of `withSentry` from `@sentry/cloudflare`' , ( ) => {
117+ vi . stubGlobal ( 'navigator' , { userAgent : 'Cloudflare-Workers' } ) ;
118+ setAsyncLocalStorageAsyncContextStrategy ( ) ;
119+
120+ withIsolationScope ( ( ) => {
121+ init ( { } ) ;
122+ init ( { } ) ;
123+ } ) ;
124+
114125 expect (
115126 getGlobalScope ( )
116127 . getScopeData ( )
117- . eventProcessors . map ( processor => processor . id ) ,
118- ) . toContain ( 'DropReactControlFlowErrors' ) ;
128+ . eventProcessors . filter ( processor => processor . id === 'DropReactControlFlowErrors' ) ,
129+ ) . toHaveLength ( 1 ) ;
119130 } ) ;
120131
121132 it ( 'inits on Cloudflare Workers outside of a request of `withSentry` from `@sentry/cloudflare`' , ( ) => {
0 commit comments