@@ -22,7 +22,6 @@ import {
2222} from '@sentry/core' ;
2323import { DEBUG_BUILD } from './debug-build' ;
2424import { captureRemixServerException , errorHandleDataFunction , errorHandleDocumentRequestFunction } from './errors' ;
25- import { getFutureFlagsServer , getRemixVersionFromBuild } from './futureFlags' ;
2625import type { RemixOptions } from './remixOptions' ;
2726import { createRoutes , getTransactionName } from './utils' ;
2827import { extractData , isDeferredData , isResponse , isRouteErrorResponse , json } from './vendor/response' ;
@@ -33,7 +32,6 @@ import type {
3332 DataFunction ,
3433 DataFunctionArgs ,
3534 EntryContext ,
36- FutureConfig ,
3735 HandleDocumentRequestFunction ,
3836 RemixRequest ,
3937 RequestHandler ,
@@ -42,8 +40,6 @@ import type {
4240 ServerRouteManifest ,
4341} from './vendor/types' ;
4442
45- let FUTURE_FLAGS : FutureConfig | undefined ;
46-
4743const redirectStatusCodes = new Set ( [ 301 , 302 , 303 , 307 , 308 ] ) ;
4844function isRedirectResponse ( response : Response ) : boolean {
4945 return redirectStatusCodes . has ( response . status ) ;
@@ -67,7 +63,6 @@ export function sentryHandleError(err: unknown, { request }: DataFunctionArgs):
6763 // We don't want to capture them twice.
6864 // This function is only for capturing unhandled server-side exceptions.
6965 // https://remix.run/docs/en/main/file-conventions/entry.server#thrown-responses
70- // https://remix.run/docs/en/v1/api/conventions#throwing-responses-in-loaders
7166 if ( isResponse ( err ) || isRouteErrorResponse ( err ) ) {
7267 return ;
7368 }
@@ -99,7 +94,7 @@ export function wrapHandleErrorWithSentry(
9994 } ;
10095}
10196
102- function makeWrappedDocumentRequestFunction ( autoInstrumentRemix ?: boolean , remixVersion ?: number ) {
97+ function makeWrappedDocumentRequestFunction ( autoInstrumentRemix ?: boolean ) {
10398 return function ( origDocumentRequestFunction : HandleDocumentRequestFunction ) : HandleDocumentRequestFunction {
10499 return async function (
105100 this : unknown ,
@@ -117,8 +112,6 @@ function makeWrappedDocumentRequestFunction(autoInstrumentRemix?: boolean, remix
117112 loadContext,
118113 } ;
119114
120- const isRemixV2 = FUTURE_FLAGS ?. v2_errorBoundary || remixVersion === 2 ;
121-
122115 if ( ! autoInstrumentRemix ) {
123116 const activeSpan = getActiveSpan ( ) ;
124117 const rootSpan = activeSpan && getRootSpan ( activeSpan ) ;
@@ -139,21 +132,11 @@ function makeWrappedDocumentRequestFunction(autoInstrumentRemix?: boolean, remix
139132 } ,
140133 } ,
141134 ( ) => {
142- return errorHandleDocumentRequestFunction . call (
143- this ,
144- origDocumentRequestFunction ,
145- documentRequestContext ,
146- isRemixV2 ,
147- ) ;
135+ return errorHandleDocumentRequestFunction . call ( this , origDocumentRequestFunction , documentRequestContext ) ;
148136 } ,
149137 ) ;
150138 } else {
151- return errorHandleDocumentRequestFunction . call (
152- this ,
153- origDocumentRequestFunction ,
154- documentRequestContext ,
155- isRemixV2 ,
156- ) ;
139+ return errorHandleDocumentRequestFunction . call ( this , origDocumentRequestFunction , documentRequestContext ) ;
157140 }
158141 } ;
159142 } ;
@@ -163,12 +146,9 @@ function makeWrappedDataFunction(
163146 origFn : DataFunction ,
164147 id : string ,
165148 name : 'action' | 'loader' ,
166- remixVersion : number ,
167149 autoInstrumentRemix ?: boolean ,
168150) : DataFunction {
169151 return async function ( this : unknown , args : DataFunctionArgs ) : Promise < Response | AppData > {
170- const isRemixV2 = FUTURE_FLAGS ?. v2_errorBoundary || remixVersion === 2 ;
171-
172152 if ( ! autoInstrumentRemix ) {
173153 return startSpan (
174154 {
@@ -180,25 +160,25 @@ function makeWrappedDataFunction(
180160 } ,
181161 } ,
182162 ( span : Span ) => {
183- return errorHandleDataFunction . call ( this , origFn , name , args , isRemixV2 , span ) ;
163+ return errorHandleDataFunction . call ( this , origFn , name , args , span ) ;
184164 } ,
185165 ) ;
186166 } else {
187- return errorHandleDataFunction . call ( this , origFn , name , args , isRemixV2 ) ;
167+ return errorHandleDataFunction . call ( this , origFn , name , args ) ;
188168 }
189169 } ;
190170}
191171
192172const makeWrappedAction =
193- ( id : string , remixVersion : number , autoInstrumentRemix ?: boolean ) =>
173+ ( id : string , autoInstrumentRemix ?: boolean ) =>
194174 ( origAction : DataFunction ) : DataFunction => {
195- return makeWrappedDataFunction ( origAction , id , 'action' , remixVersion , autoInstrumentRemix ) ;
175+ return makeWrappedDataFunction ( origAction , id , 'action' , autoInstrumentRemix ) ;
196176 } ;
197177
198178const makeWrappedLoader =
199- ( id : string , remixVersion : number , autoInstrumentRemix ?: boolean ) =>
179+ ( id : string , autoInstrumentRemix ?: boolean ) =>
200180 ( origLoader : DataFunction ) : DataFunction => {
201- return makeWrappedDataFunction ( origLoader , id , 'loader' , remixVersion , autoInstrumentRemix ) ;
181+ return makeWrappedDataFunction ( origLoader , id , 'loader' , autoInstrumentRemix ) ;
202182 } ;
203183
204184function getTraceAndBaggage ( ) : {
@@ -217,7 +197,7 @@ function getTraceAndBaggage(): {
217197 return { } ;
218198}
219199
220- function makeWrappedRootLoader ( remixVersion : number ) {
200+ function makeWrappedRootLoader ( ) {
221201 return function ( origLoader : DataFunction ) : DataFunction {
222202 return async function ( this : unknown , args : DataFunctionArgs ) : Promise < Response | AppData > {
223203 const res = await origLoader . call ( this , args ) ;
@@ -226,7 +206,6 @@ function makeWrappedRootLoader(remixVersion: number) {
226206 if ( isDeferredData ( res ) ) {
227207 res . data [ 'sentryTrace' ] = traceAndBaggage . sentryTrace ;
228208 res . data [ 'sentryBaggage' ] = traceAndBaggage . sentryBaggage ;
229- res . data [ 'remixVersion' ] = remixVersion ;
230209
231210 return res ;
232211 }
@@ -243,7 +222,7 @@ function makeWrappedRootLoader(remixVersion: number) {
243222
244223 if ( typeof data === 'object' ) {
245224 return json (
246- { ...data , ...traceAndBaggage , remixVersion } ,
225+ { ...data , ...traceAndBaggage } ,
247226 {
248227 headers : res . headers ,
249228 statusText : res . statusText ,
@@ -257,7 +236,7 @@ function makeWrappedRootLoader(remixVersion: number) {
257236 }
258237 }
259238
260- return { ...res , ...traceAndBaggage , remixVersion } ;
239+ return { ...res , ...traceAndBaggage } ;
261240 } ;
262241 } ;
263242}
@@ -351,7 +330,6 @@ function wrapRequestHandler(
351330
352331function instrumentBuildCallback ( build : ServerBuild , autoInstrumentRemix : boolean ) : ServerBuild {
353332 const routes : ServerRouteManifest = { } ;
354- const remixVersion = getRemixVersionFromBuild ( build ) ;
355333 const wrappedEntry = { ...build . entry , module : { ...build . entry . module } } ;
356334
357335 // Not keeping boolean flags like it's done for `requestHandler` functions,
@@ -360,20 +338,20 @@ function instrumentBuildCallback(build: ServerBuild, autoInstrumentRemix: boolea
360338 // We should be able to wrap them, as they may not be wrapped before.
361339 const defaultExport = wrappedEntry . module . default as undefined | WrappedFunction ;
362340 if ( defaultExport && ! defaultExport . __sentry_original__ ) {
363- fill ( wrappedEntry . module , 'default' , makeWrappedDocumentRequestFunction ( autoInstrumentRemix , remixVersion ) ) ;
341+ fill ( wrappedEntry . module , 'default' , makeWrappedDocumentRequestFunction ( autoInstrumentRemix ) ) ;
364342 }
365343
366344 for ( const [ id , route ] of Object . entries ( build . routes ) ) {
367345 const wrappedRoute = { ...route , module : { ...route . module } } ;
368346
369347 const routeAction = wrappedRoute . module . action as undefined | WrappedFunction ;
370348 if ( routeAction && ! routeAction . __sentry_original__ ) {
371- fill ( wrappedRoute . module , 'action' , makeWrappedAction ( id , remixVersion , autoInstrumentRemix ) ) ;
349+ fill ( wrappedRoute . module , 'action' , makeWrappedAction ( id , autoInstrumentRemix ) ) ;
372350 }
373351
374352 const routeLoader = wrappedRoute . module . loader as undefined | WrappedFunction ;
375353 if ( routeLoader && ! routeLoader . __sentry_original__ ) {
376- fill ( wrappedRoute . module , 'loader' , makeWrappedLoader ( id , remixVersion , autoInstrumentRemix ) ) ;
354+ fill ( wrappedRoute . module , 'loader' , makeWrappedLoader ( id , autoInstrumentRemix ) ) ;
377355 }
378356
379357 // Entry module should have a loader function to provide `sentry-trace` and `baggage`
@@ -384,7 +362,7 @@ function instrumentBuildCallback(build: ServerBuild, autoInstrumentRemix: boolea
384362 }
385363
386364 // We want to wrap the root loader regardless of whether it's already wrapped before.
387- fill ( wrappedRoute . module , 'loader' , makeWrappedRootLoader ( remixVersion ) ) ;
365+ fill ( wrappedRoute . module , 'loader' , makeWrappedRootLoader ( ) ) ;
388366 }
389367
390368 routes [ id ] = wrappedRoute ;
@@ -409,19 +387,13 @@ export function instrumentBuild(
409387
410388 if ( resolvedBuild instanceof Promise ) {
411389 return resolvedBuild . then ( build => {
412- FUTURE_FLAGS = getFutureFlagsServer ( build ) ;
413-
414390 return instrumentBuildCallback ( build , autoInstrumentRemix ) ;
415391 } ) ;
416392 } else {
417- FUTURE_FLAGS = getFutureFlagsServer ( resolvedBuild ) ;
418-
419393 return instrumentBuildCallback ( resolvedBuild , autoInstrumentRemix ) ;
420394 }
421395 } ;
422396 } else {
423- FUTURE_FLAGS = getFutureFlagsServer ( build ) ;
424-
425397 return instrumentBuildCallback ( build , autoInstrumentRemix ) ;
426398 }
427399}
0 commit comments