Skip to content

Commit

Permalink
fix(RequestHandler): do not clone request for internal phases
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Oct 10, 2023
1 parent d83a516 commit 6017b5f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/handlers/RequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export abstract class RequestHandler<
resolutionContext?: ResponseResolutionContext
}): Promise<boolean> {
const parsedResult = await this.parse({
request: args.request.clone(),
request: args.request,
resolutionContext: args.resolutionContext,
})

Expand Down Expand Up @@ -186,6 +186,8 @@ export abstract class RequestHandler<
return null
}

// Clone the request instance before it's passed to the handler phases
// and the response resolver so we can always read it for logging.
const mainRequestRef = args.request.clone()

// Immediately mark the handler as used.
Expand All @@ -194,11 +196,11 @@ export abstract class RequestHandler<
this.isUsed = true

const parsedResult = await this.parse({
request: mainRequestRef.clone(),
request: args.request,
resolutionContext: args.resolutionContext,
})
const shouldInterceptRequest = this.predicate({
request: mainRequestRef.clone(),
request: args.request,
parsedResult,
resolutionContext: args.resolutionContext,
})
Expand Down

0 comments on commit 6017b5f

Please sign in to comment.