From 38ebf4e2e00d245430cacf0e6e74925dec082bb3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Sep 2025 19:48:15 +0000 Subject: [PATCH 1/2] Initial plan From c4c5aed4a7eed568b6a707834d9b909e44581393 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Sep 2025 19:54:48 +0000 Subject: [PATCH 2/2] Implement unstable_rethrow fix for auth redirect errors in try/catch blocks Co-Authored-By: bookernath <8922457+bookernath@users.noreply.github.com> --- .changeset/angry-kids-listen.md | 5 +++++ .../(default)/account/addresses/_actions/create-address.ts | 3 +++ .../(default)/account/settings/_actions/change-password.ts | 3 +++ .../(default)/account/settings/_actions/update-customer.ts | 3 +++ .../account/wishlists/[id]/_actions/add-to-cart.tsx | 3 +++ .../(default)/account/wishlists/_actions/new-wishlist.ts | 3 +++ .../account/wishlists/_actions/remove-wishlist-item.ts | 3 +++ .../app/[locale]/(default)/cart/_actions/update-line-item.ts | 5 +++++ core/app/[locale]/(default)/compare/_actions/add-to-cart.tsx | 3 +++ .../(default)/product/[slug]/_actions/add-to-cart.tsx | 3 +++ .../(default)/product/[slug]/_actions/wishlist-action.ts | 3 +++ 11 files changed, 37 insertions(+) create mode 100644 .changeset/angry-kids-listen.md diff --git a/.changeset/angry-kids-listen.md b/.changeset/angry-kids-listen.md new file mode 100644 index 0000000000..acad2f3872 --- /dev/null +++ b/.changeset/angry-kids-listen.md @@ -0,0 +1,5 @@ +--- +"@bigcommerce/catalyst-core": patch +--- + +Implement unstable_rethrow fix for auth redirect errors in try/catch blo… diff --git a/core/app/[locale]/(default)/account/addresses/_actions/create-address.ts b/core/app/[locale]/(default)/account/addresses/_actions/create-address.ts index 94c7e3dc1e..f9d86aa73a 100644 --- a/core/app/[locale]/(default)/account/addresses/_actions/create-address.ts +++ b/core/app/[locale]/(default)/account/addresses/_actions/create-address.ts @@ -1,6 +1,7 @@ import { BigCommerceAPIError, BigCommerceGQLError } from '@bigcommerce/catalyst-client'; import { parseWithZod } from '@conform-to/zod'; import { unstable_expireTag as expireTag } from 'next/cache'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { z } from 'zod'; @@ -245,6 +246,8 @@ export async function createAddress(prevState: Awaited, formData: FormDat fields: prevState.fields, }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/account/settings/_actions/change-password.ts b/core/app/[locale]/(default)/account/settings/_actions/change-password.ts index 3a5df942d9..0f2c488235 100644 --- a/core/app/[locale]/(default)/account/settings/_actions/change-password.ts +++ b/core/app/[locale]/(default)/account/settings/_actions/change-password.ts @@ -2,6 +2,7 @@ import { BigCommerceGQLError } from '@bigcommerce/catalyst-client'; import { parseWithZod } from '@conform-to/zod'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { ChangePasswordAction } from '@/vibes/soul/sections/account-settings/change-password-form'; @@ -71,6 +72,8 @@ export const changePassword: ChangePasswordAction = async (prevState, formData) successMessage: t('passwordUpdated'), }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/account/settings/_actions/update-customer.ts b/core/app/[locale]/(default)/account/settings/_actions/update-customer.ts index 8d678d562c..54520b1ce8 100644 --- a/core/app/[locale]/(default)/account/settings/_actions/update-customer.ts +++ b/core/app/[locale]/(default)/account/settings/_actions/update-customer.ts @@ -3,6 +3,7 @@ import { BigCommerceGQLError } from '@bigcommerce/catalyst-client'; import { parseWithZod } from '@conform-to/zod'; import { unstable_expireTag } from 'next/cache'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { updateAccountSchema } from '@/vibes/soul/sections/account-settings/schema'; @@ -83,6 +84,8 @@ export const updateCustomer: UpdateAccountAction = async (prevState, formData) = lastResult: submission.reply(), }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/account/wishlists/[id]/_actions/add-to-cart.tsx b/core/app/[locale]/(default)/account/wishlists/[id]/_actions/add-to-cart.tsx index 2cd0664423..3b5b2d9022 100644 --- a/core/app/[locale]/(default)/account/wishlists/[id]/_actions/add-to-cart.tsx +++ b/core/app/[locale]/(default)/account/wishlists/[id]/_actions/add-to-cart.tsx @@ -3,6 +3,7 @@ import { BigCommerceAPIError, BigCommerceGQLError } from '@bigcommerce/catalyst-client'; import { SubmissionResult } from '@conform-to/react'; import { parseWithZod } from '@conform-to/zod'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { z } from 'zod'; @@ -55,6 +56,8 @@ export async function addWishlistItemToCart(prevState: State, formData: FormData }), }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/account/wishlists/_actions/new-wishlist.ts b/core/app/[locale]/(default)/account/wishlists/_actions/new-wishlist.ts index 1df54efdc6..e2c6c232a0 100644 --- a/core/app/[locale]/(default)/account/wishlists/_actions/new-wishlist.ts +++ b/core/app/[locale]/(default)/account/wishlists/_actions/new-wishlist.ts @@ -4,6 +4,7 @@ import { BigCommerceAuthError } from '@bigcommerce/catalyst-client'; import { SubmissionResult } from '@conform-to/react'; import { parseWithZod } from '@conform-to/zod'; import { revalidateTag } from 'next/cache'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { getSessionCustomerAccessToken } from '~/auth'; @@ -65,6 +66,8 @@ export async function newWishlist(prevState: Awaited, formData: FormData) successMessage: t('Result.createSuccess'), }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/account/wishlists/_actions/remove-wishlist-item.ts b/core/app/[locale]/(default)/account/wishlists/_actions/remove-wishlist-item.ts index 5bee617081..224f405b31 100644 --- a/core/app/[locale]/(default)/account/wishlists/_actions/remove-wishlist-item.ts +++ b/core/app/[locale]/(default)/account/wishlists/_actions/remove-wishlist-item.ts @@ -4,6 +4,7 @@ import { BigCommerceAuthError } from '@bigcommerce/catalyst-client'; import { SubmissionResult } from '@conform-to/react'; import { parseWithZod } from '@conform-to/zod'; import { revalidateTag } from 'next/cache'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { getSessionCustomerAccessToken } from '~/auth'; @@ -73,6 +74,8 @@ export async function removeWishlistItem( lastResult: submission.reply(), }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/cart/_actions/update-line-item.ts b/core/app/[locale]/(default)/cart/_actions/update-line-item.ts index 2d01a290a8..9d841307c8 100644 --- a/core/app/[locale]/(default)/cart/_actions/update-line-item.ts +++ b/core/app/[locale]/(default)/cart/_actions/update-line-item.ts @@ -4,6 +4,7 @@ import { BigCommerceGQLError } from '@bigcommerce/catalyst-client'; import { SubmissionResult } from '@conform-to/react'; import { parseWithZod } from '@conform-to/zod'; import { FragmentOf } from 'gql.tada'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { CartLineItem } from '@/vibes/soul/sections/cart'; @@ -332,6 +333,8 @@ export const updateLineItem = async ( quantity: cartLineItem.quantity - 1, }); } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); @@ -365,6 +368,8 @@ export const updateLineItem = async ( try { await removeItem({ lineItemEntityId: submission.value.id }); } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/compare/_actions/add-to-cart.tsx b/core/app/[locale]/(default)/compare/_actions/add-to-cart.tsx index d04cdc1536..8d654d7f0e 100644 --- a/core/app/[locale]/(default)/compare/_actions/add-to-cart.tsx +++ b/core/app/[locale]/(default)/compare/_actions/add-to-cart.tsx @@ -3,6 +3,7 @@ import { BigCommerceGQLError } from '@bigcommerce/catalyst-client'; import { SubmissionResult } from '@conform-to/react'; import { parseWithZod } from '@conform-to/zod'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { ReactNode } from 'react'; @@ -57,6 +58,8 @@ export const addToCart = async ( }), }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/product/[slug]/_actions/add-to-cart.tsx b/core/app/[locale]/(default)/product/[slug]/_actions/add-to-cart.tsx index a3f790bf8a..ac0039cbe1 100644 --- a/core/app/[locale]/(default)/product/[slug]/_actions/add-to-cart.tsx +++ b/core/app/[locale]/(default)/product/[slug]/_actions/add-to-cart.tsx @@ -3,6 +3,7 @@ import { BigCommerceGQLError } from '@bigcommerce/catalyst-client'; import { SubmissionResult } from '@conform-to/react'; import { parseWithZod } from '@conform-to/zod'; +import { unstable_rethrow } from 'next/navigation'; import { getTranslations } from 'next-intl/server'; import { ReactNode } from 'react'; @@ -175,6 +176,8 @@ export const addToCart = async ( }), }; } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error); diff --git a/core/app/[locale]/(default)/product/[slug]/_actions/wishlist-action.ts b/core/app/[locale]/(default)/product/[slug]/_actions/wishlist-action.ts index faa4368e3d..c081a0fdce 100644 --- a/core/app/[locale]/(default)/product/[slug]/_actions/wishlist-action.ts +++ b/core/app/[locale]/(default)/product/[slug]/_actions/wishlist-action.ts @@ -8,6 +8,7 @@ import { import { SubmissionResult } from '@conform-to/react'; import { parseWithZod } from '@conform-to/zod'; import { revalidateTag } from 'next/cache'; +import { unstable_rethrow } from 'next/navigation'; import { getLocale, getTranslations } from 'next-intl/server'; import { z } from 'zod'; @@ -237,6 +238,8 @@ export async function wishlistAction(payload: FormData): Promise { revalidateTag(TAGS.customer); } catch (error) { + unstable_rethrow(error); + // eslint-disable-next-line no-console console.error(error);