From 4c75f859a299b0f92146b347fa4c58c2e55db625 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Mon, 27 Nov 2023 14:22:31 +0000 Subject: [PATCH] fix(remix): Skip capturing aborted requests. (#9659) Remix documentation suggests users avoid capturing aborted requests. --- packages/remix/src/utils/instrumentServer.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/remix/src/utils/instrumentServer.ts b/packages/remix/src/utils/instrumentServer.ts index 935e24124b49..714b6b51e09f 100644 --- a/packages/remix/src/utils/instrumentServer.ts +++ b/packages/remix/src/utils/instrumentServer.ts @@ -89,6 +89,13 @@ export async function captureRemixServerException(err: unknown, name: string, re return; } + // Skip capturing if the request is aborted as Remix docs suggest + // Ref: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror + if (request.signal.aborted) { + __DEBUG_BUILD__ && logger.warn('Skipping capture of aborted request'); + return; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any let normalizedRequest: Record = request as unknown as any;