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

fix(remix-server-runtime): use correct error/catch boundary on SSR action errors #3436

Merged
merged 2 commits into from
Jun 10, 2022

Conversation

brophdawg11
Copy link
Contributor

Closes: #599

  • Tests

Testing Strategy: I tested using the repo in #599 but the repro setup is basically:

  • Parent route with loader data
  • Child route that exports ErrorBoundary or CatchBoundary
  • Child contains form or <Form reloadDocument={true}> submitting to child action that throws
    • This error only happens in server-side form submissions
  • Proper boundary should be used and the parent loaderData should not be wiped away on submission

"CatchBoundary"
);
).slice(0, -1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't want to slice and then look for the boundary, otherwise we miss leaf boundaries. Instead, find the boundary then slice so we don't run the loader for the boundary route.

@@ -880,7 +880,8 @@ describe("shared server runtime", () => {
let result = await handler(request);
expect(result.status).toBe(400);
expect(testAction.mock.calls.length).toBe(1);
expect(rootLoader.mock.calls.length).toBe(1);
// Should not call root loader since it is the boundary route
expect(rootLoader.mock.calls.length).toBe(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These unit tests were previously invalid - if we throw from the child and it gets handled by the root - we do not want to re-run the root loader

@MichaelDeBoey MichaelDeBoey changed the title fix: use correct error/catch boundary on SSR action errors fix(remix-server-runtime): use correct error/catch boundary on SSR action errors Jun 10, 2022
@ryanflorence ryanflorence merged commit ee36a01 into dev Jun 10, 2022
@ryanflorence ryanflorence deleted the brophdawg11/action-boundary-bug branch June 10, 2022 21:24
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v1.6.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v1.6.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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.

[Bug]: Loader data gets undefined when an error is thrown in a child route
3 participants