File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
packages/remix/src/server Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -320,17 +320,18 @@ function wrapRequestHandler<T extends ServerBuild | (() => ServerBuild | Promise
320320 instrumentTracing ?: boolean ;
321321 } ,
322322) : RequestHandler {
323- let resolvedBuild : ServerBuild | { build : ServerBuild } ;
324- let name : string ;
325- let source : TransactionSource ;
326-
327323 return async function ( this : unknown , request : RemixRequest , loadContext ?: AppLoadContext ) : Promise < Response > {
328324 const upperCaseMethod = request . method . toUpperCase ( ) ;
329325 // We don't want to wrap OPTIONS and HEAD requests
330326 if ( upperCaseMethod === 'OPTIONS' || upperCaseMethod === 'HEAD' ) {
331327 return origRequestHandler . call ( this , request , loadContext ) ;
332328 }
333329
330+ // These variables are declared inside the async function to avoid race conditions
331+ // across concurrent requests. Each request gets its own instance.
332+ let resolvedBuild : ServerBuild | { build : ServerBuild } ;
333+ let name : string ;
334+ let source : TransactionSource ;
334335 let resolvedRoutes : AgnosticRouteObject [ ] | undefined ;
335336
336337 if ( options ?. instrumentTracing ) {
You can’t perform that action at this time.
0 commit comments