Skip to content

Commit f7db230

Browse files
authored
feat(remix): Skip span creation for OPTIONS and HEAD requests. (#11149)
Fixes: #11105 Skips span creation for `OPTIONS` and `HEAD` requests in `wrapRequestHandler`, which apparently are the unwanted requests mentioned in #11105. We can also implement a more precise filtering but this seems to resolve it on my local test application.
1 parent 022fcb6 commit f7db230

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/remix/src/utils/instrumentServer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ function wrapRequestHandler(origRequestHandler: RequestHandler, build: ServerBui
430430
return origRequestHandler.call(this, request, loadContext);
431431
}
432432

433+
const upperCaseMethod = request.method.toUpperCase();
434+
435+
// We don't want to wrap OPTIONS and HEAD requests
436+
if (upperCaseMethod === 'OPTIONS' || upperCaseMethod === 'HEAD') {
437+
return origRequestHandler.call(this, request, loadContext);
438+
}
439+
433440
return withIsolationScope(async isolationScope => {
434441
const options = getClient()?.getOptions();
435442

0 commit comments

Comments
 (0)