Skip to content
Merged
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
7 changes: 3 additions & 4 deletions packages/remix/src/server/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ export function errorHandleDocumentRequestFunction(
const { request, responseStatusCode, responseHeaders, context, loadContext } = requestContext;

return handleCallbackErrors(
() => {
return origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context, loadContext);
},
() => origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context, loadContext),
err => {
throw err;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
captureRemixServerException(err, 'HandleDocumentRequestFunction', request);
},

Choose a reason for hiding this comment

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

Potential bug: The error callback for HandleDocumentRequestFunction no longer re-throws errors, swallowing exceptions and breaking the error handling flow for document requests.
  • Description: The onError callback for errorHandleDocumentRequestFunction no longer re-throws the caught error. This violates the contract of the handleCallbackErrors utility, which is designed to always propagate exceptions after executing the callback. By removing throw err;, any error occurring during the server-side document rendering process is captured but then swallowed. This prevents Remix's higher-level error handling from triggering, which can lead to clients receiving incomplete or invalid HTML responses instead of a proper error page, while the server continues in an inconsistent state.

  • Suggested fix: Restore the original behavior by re-adding throw err; at the end of the onError callback. This ensures that after the exception is captured, it is correctly propagated, allowing Remix's standard error handling mechanisms to generate a proper error response.
    severity: 0.85, confidence: 0.98

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Member Author

Choose a reason for hiding this comment

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

this already re-throws out of the box.

);
}
Expand Down
Loading