From ee7114a920397a709b76f8285aefc6cffd9023dc Mon Sep 17 00:00:00 2001 From: poetry by <2638986+btomaj@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:26:56 +1100 Subject: [PATCH] Fix Remix redirect on bounce --- .changeset/tender-rings-invite.md | 5 +++++ .../src/server/boundary/__tests__/error.test.tsx | 11 +++++++++++ .../shopify-app-remix/src/server/boundary/error.tsx | 5 ++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/tender-rings-invite.md diff --git a/.changeset/tender-rings-invite.md b/.changeset/tender-rings-invite.md new file mode 100644 index 0000000000..35deb8f174 --- /dev/null +++ b/.changeset/tender-rings-invite.md @@ -0,0 +1,5 @@ +--- +'@shopify/shopify-app-remix': patch +--- + +Fixed the errorBoundary to work with new cases in Remix v2. diff --git a/packages/shopify-app-remix/src/server/boundary/__tests__/error.test.tsx b/packages/shopify-app-remix/src/server/boundary/__tests__/error.test.tsx index 74ddfea3f6..77e3c3b17d 100644 --- a/packages/shopify-app-remix/src/server/boundary/__tests__/error.test.tsx +++ b/packages/shopify-app-remix/src/server/boundary/__tests__/error.test.tsx @@ -13,6 +13,16 @@ describe('Error boundary', () => { ); }); + it('returns a string when handling an ErrorResponseImpl', () => { + // WHEN + const result = boundary.error(new ErrorResponseImpl()); + + // THEN + expect(result).toEqual( +
, + ); + }); + it('throws an error when handling an unknown error', () => { // WHEN const result = () => boundary.error(new Error()); @@ -23,3 +33,4 @@ describe('Error boundary', () => { }); class ErrorResponse extends Error {} +class ErrorResponseImpl extends Error {} diff --git a/packages/shopify-app-remix/src/server/boundary/error.tsx b/packages/shopify-app-remix/src/server/boundary/error.tsx index a0c816a2c8..2a8a737824 100644 --- a/packages/shopify-app-remix/src/server/boundary/error.tsx +++ b/packages/shopify-app-remix/src/server/boundary/error.tsx @@ -1,5 +1,8 @@ export function errorBoundary(error: any) { - if (error.constructor.name === 'ErrorResponse') { + if ( + error.constructor.name === 'ErrorResponse' || + error.constructor.name === 'ErrorResponseImpl' + ) { return (