Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore: don't log server errors for aborted requests #5602

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/no-log-on-aborted-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/server-runtime": patch
---

Don't log server errors for aborted requests as that is an expected flow
10 changes: 6 additions & 4 deletions packages/remix-server-runtime/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ async function handleDocumentRequestRR(
entryContext
);
} catch (error: any) {
if (serverMode !== ServerMode.Test && !request.signal.aborted) {
console.error(error);
}
return returnLastResortErrorResponse(error, serverMode);
}
}
Expand Down Expand Up @@ -369,6 +372,9 @@ async function handleResourceRequestRR(
error.headers.set("X-Remix-Catch", "yes");
return error;
}
if (serverMode !== ServerMode.Test && !request.signal.aborted) {
console.error(error);
}
return returnLastResortErrorResponse(error, serverMode);
}
}
Expand All @@ -383,10 +389,6 @@ async function errorBoundaryError(error: Error, status: number) {
}

function returnLastResortErrorResponse(error: any, serverMode?: ServerMode) {
if (serverMode !== ServerMode.Test) {
console.error(error);
}
Copy link
Contributor Author

@brophdawg11 brophdawg11 Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the log to a utility that does the checking and lifted to the 2 places we call returnLastResortErrorResponse


let message = "Unexpected Server Error";

if (serverMode !== ServerMode.Production) {
Expand Down