Skip to content

Commit c4c5aed

Browse files
Copilotbookernath
andcommitted
Implement unstable_rethrow fix for auth redirect errors in try/catch blocks
Co-Authored-By: bookernath <[email protected]>
1 parent 38ebf4e commit c4c5aed

File tree

11 files changed

+37
-0
lines changed

11 files changed

+37
-0
lines changed

.changeset/angry-kids-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
Implement unstable_rethrow fix for auth redirect errors in try/catch blo…

core/app/[locale]/(default)/account/addresses/_actions/create-address.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BigCommerceAPIError, BigCommerceGQLError } from '@bigcommerce/catalyst-client';
22
import { parseWithZod } from '@conform-to/zod';
33
import { unstable_expireTag as expireTag } from 'next/cache';
4+
import { unstable_rethrow } from 'next/navigation';
45
import { getTranslations } from 'next-intl/server';
56
import { z } from 'zod';
67

@@ -245,6 +246,8 @@ export async function createAddress(prevState: Awaited<State>, formData: FormDat
245246
fields: prevState.fields,
246247
};
247248
} catch (error) {
249+
unstable_rethrow(error);
250+
248251
// eslint-disable-next-line no-console
249252
console.error(error);
250253

core/app/[locale]/(default)/account/settings/_actions/change-password.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { BigCommerceGQLError } from '@bigcommerce/catalyst-client';
44
import { parseWithZod } from '@conform-to/zod';
5+
import { unstable_rethrow } from 'next/navigation';
56
import { getTranslations } from 'next-intl/server';
67

78
import { ChangePasswordAction } from '@/vibes/soul/sections/account-settings/change-password-form';
@@ -71,6 +72,8 @@ export const changePassword: ChangePasswordAction = async (prevState, formData)
7172
successMessage: t('passwordUpdated'),
7273
};
7374
} catch (error) {
75+
unstable_rethrow(error);
76+
7477
// eslint-disable-next-line no-console
7578
console.error(error);
7679

core/app/[locale]/(default)/account/settings/_actions/update-customer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { BigCommerceGQLError } from '@bigcommerce/catalyst-client';
44
import { parseWithZod } from '@conform-to/zod';
55
import { unstable_expireTag } from 'next/cache';
6+
import { unstable_rethrow } from 'next/navigation';
67
import { getTranslations } from 'next-intl/server';
78

89
import { updateAccountSchema } from '@/vibes/soul/sections/account-settings/schema';
@@ -83,6 +84,8 @@ export const updateCustomer: UpdateAccountAction = async (prevState, formData) =
8384
lastResult: submission.reply(),
8485
};
8586
} catch (error) {
87+
unstable_rethrow(error);
88+
8689
// eslint-disable-next-line no-console
8790
console.error(error);
8891

core/app/[locale]/(default)/account/wishlists/[id]/_actions/add-to-cart.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { BigCommerceAPIError, BigCommerceGQLError } from '@bigcommerce/catalyst-client';
44
import { SubmissionResult } from '@conform-to/react';
55
import { parseWithZod } from '@conform-to/zod';
6+
import { unstable_rethrow } from 'next/navigation';
67
import { getTranslations } from 'next-intl/server';
78
import { z } from 'zod';
89

@@ -55,6 +56,8 @@ export async function addWishlistItemToCart(prevState: State, formData: FormData
5556
}),
5657
};
5758
} catch (error) {
59+
unstable_rethrow(error);
60+
5861
// eslint-disable-next-line no-console
5962
console.error(error);
6063

core/app/[locale]/(default)/account/wishlists/_actions/new-wishlist.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BigCommerceAuthError } from '@bigcommerce/catalyst-client';
44
import { SubmissionResult } from '@conform-to/react';
55
import { parseWithZod } from '@conform-to/zod';
66
import { revalidateTag } from 'next/cache';
7+
import { unstable_rethrow } from 'next/navigation';
78
import { getTranslations } from 'next-intl/server';
89

910
import { getSessionCustomerAccessToken } from '~/auth';
@@ -65,6 +66,8 @@ export async function newWishlist(prevState: Awaited<State>, formData: FormData)
6566
successMessage: t('Result.createSuccess'),
6667
};
6768
} catch (error) {
69+
unstable_rethrow(error);
70+
6871
// eslint-disable-next-line no-console
6972
console.error(error);
7073

core/app/[locale]/(default)/account/wishlists/_actions/remove-wishlist-item.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BigCommerceAuthError } from '@bigcommerce/catalyst-client';
44
import { SubmissionResult } from '@conform-to/react';
55
import { parseWithZod } from '@conform-to/zod';
66
import { revalidateTag } from 'next/cache';
7+
import { unstable_rethrow } from 'next/navigation';
78
import { getTranslations } from 'next-intl/server';
89

910
import { getSessionCustomerAccessToken } from '~/auth';
@@ -73,6 +74,8 @@ export async function removeWishlistItem(
7374
lastResult: submission.reply(),
7475
};
7576
} catch (error) {
77+
unstable_rethrow(error);
78+
7679
// eslint-disable-next-line no-console
7780
console.error(error);
7881

core/app/[locale]/(default)/cart/_actions/update-line-item.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BigCommerceGQLError } from '@bigcommerce/catalyst-client';
44
import { SubmissionResult } from '@conform-to/react';
55
import { parseWithZod } from '@conform-to/zod';
66
import { FragmentOf } from 'gql.tada';
7+
import { unstable_rethrow } from 'next/navigation';
78
import { getTranslations } from 'next-intl/server';
89

910
import { CartLineItem } from '@/vibes/soul/sections/cart';
@@ -332,6 +333,8 @@ export const updateLineItem = async (
332333
quantity: cartLineItem.quantity - 1,
333334
});
334335
} catch (error) {
336+
unstable_rethrow(error);
337+
335338
// eslint-disable-next-line no-console
336339
console.error(error);
337340

@@ -365,6 +368,8 @@ export const updateLineItem = async (
365368
try {
366369
await removeItem({ lineItemEntityId: submission.value.id });
367370
} catch (error) {
371+
unstable_rethrow(error);
372+
368373
// eslint-disable-next-line no-console
369374
console.error(error);
370375

core/app/[locale]/(default)/compare/_actions/add-to-cart.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { BigCommerceGQLError } from '@bigcommerce/catalyst-client';
44
import { SubmissionResult } from '@conform-to/react';
55
import { parseWithZod } from '@conform-to/zod';
6+
import { unstable_rethrow } from 'next/navigation';
67
import { getTranslations } from 'next-intl/server';
78
import { ReactNode } from 'react';
89

@@ -57,6 +58,8 @@ export const addToCart = async (
5758
}),
5859
};
5960
} catch (error) {
61+
unstable_rethrow(error);
62+
6063
// eslint-disable-next-line no-console
6164
console.error(error);
6265

core/app/[locale]/(default)/product/[slug]/_actions/add-to-cart.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { BigCommerceGQLError } from '@bigcommerce/catalyst-client';
44
import { SubmissionResult } from '@conform-to/react';
55
import { parseWithZod } from '@conform-to/zod';
6+
import { unstable_rethrow } from 'next/navigation';
67
import { getTranslations } from 'next-intl/server';
78
import { ReactNode } from 'react';
89

@@ -175,6 +176,8 @@ export const addToCart = async (
175176
}),
176177
};
177178
} catch (error) {
179+
unstable_rethrow(error);
180+
178181
// eslint-disable-next-line no-console
179182
console.error(error);
180183

0 commit comments

Comments
 (0)