Skip to content

Commit 85408af

Browse files
committed
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 43b83a6 commit 85408af

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
@@ -446,6 +446,13 @@ function wrapRequestHandler(origRequestHandler: RequestHandler, build: ServerBui
446446
return origRequestHandler.call(this, request, loadContext);
447447
}
448448

449+
const upperCaseMethod = request.method.toUpperCase();
450+
451+
// We don't want to wrap OPTIONS and HEAD requests
452+
if (upperCaseMethod === 'OPTIONS' || upperCaseMethod === 'HEAD') {
453+
return origRequestHandler.call(this, request, loadContext);
454+
}
455+
449456
return runWithAsyncContext(async () => {
450457
// eslint-disable-next-line deprecation/deprecation
451458
const hub = getCurrentHub();

0 commit comments

Comments
 (0)