Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add outer RemixErrorBoundary to catch root boundary-thrown errors #5012

Merged
merged 6 commits into from
Jan 6, 2023

Conversation

brophdawg11
Copy link
Contributor

Needed to add back in a global RemixErrorBoundary wrapper around the full application in case the root route threw from it's own boundary.

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2023

🦋 Changeset detected

Latest commit: f789bbd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@remix-run/react Patch
@remix-run/testing Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/deno Patch
@remix-run/dev Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/netlify Patch
@remix-run/node Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -875,3 +875,329 @@ test.describe("loaderData in ErrorBoundary", () => {
});
}
});

test.describe("Default ErrorBoundary", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Document request + SPA transition tests for:

  • no root boundary
  • root boundary
  • root boundary that throws

@@ -259,7 +259,7 @@ async function handleDocumentRequestRR(
);
} catch (error: unknown) {
if (serverMode !== ServerMode.Test) {
console.log("Error in entry.server handleDocumentRequest:", error);
console.error("Error in entry.server handleDocumentRequest:", error);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

console.error is what we used to use - and explains why we started seeing these in integration tests since we only blew away console.error

Comment on lines -58 to +79
<RouterProvider router={router} fallbackElement={null} />
<RemixErrorBoundary
location={location}
component={RemixRootDefaultErrorBoundary}
>
<RouterProvider router={router} fallbackElement={null} />
</RemixErrorBoundary>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrap everything in a last-resort error boundary, and send the router location in so users can back-button out of it

Comment on lines -261 to -263
if (serverMode !== ServerMode.Test) {
console.log("Error in entry.server handleDocumentRequest:", error);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This turns out to be a dup - we have a console.error in returnLastResortErrorResponse and in remix 1.7.6 that's the only one we would log so removed this to remain consistent (and since we had a unit test asserting this!). Eventually I think we'll have some hooks to get at this kind of stuff where users can do their own logging.

brophdawg11 and others added 2 commits January 6, 2023 10:26
Co-authored-by: Jacob Ebey <jacob.ebey@live.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants