Skip to content

Commit 1a6fcb9

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 1a6fcb9

File tree

11 files changed

+9376
-0
lines changed

11 files changed

+9376
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ export async function createAddress(prevState: Awaited<State>, formData: FormDat
245245
fields: prevState.fields,
246246
};
247247
} catch (error) {
248+
unstable_rethrow(error);
249+
248250
// eslint-disable-next-line no-console
249251
console.error(error);
250252

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export const changePassword: ChangePasswordAction = async (prevState, formData)
7171
successMessage: t('passwordUpdated'),
7272
};
7373
} catch (error) {
74+
unstable_rethrow(error);
75+
7476
// eslint-disable-next-line no-console
7577
console.error(error);
7678

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

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

89
import { updateAccountSchema } from '@/vibes/soul/sections/account-settings/schema';
910
import { UpdateAccountAction } from '@/vibes/soul/sections/account-settings/update-account-form';
@@ -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
@@ -4,6 +4,7 @@ import { BigCommerceAPIError, BigCommerceGQLError } from '@bigcommerce/catalyst-
44
import { SubmissionResult } from '@conform-to/react';
55
import { parseWithZod } from '@conform-to/zod';
66
import { getTranslations } from 'next-intl/server';
7+
import { unstable_rethrow } from 'next/navigation';
78
import { z } from 'zod';
89

910
import { Link } from '~/components/link';
@@ -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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export async function newWishlist(prevState: Awaited<State>, formData: FormData)
6565
successMessage: t('Result.createSuccess'),
6666
};
6767
} catch (error) {
68+
unstable_rethrow(error);
69+
6870
// eslint-disable-next-line no-console
6971
console.error(error);
7072

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export async function removeWishlistItem(
7373
lastResult: submission.reply(),
7474
};
7575
} catch (error) {
76+
unstable_rethrow(error);
77+
7678
// eslint-disable-next-line no-console
7779
console.error(error);
7880

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

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

910
import { CartLineItem } from '@/vibes/soul/sections/cart';
1011
import { cartLineItemActionFormDataSchema } from '@/vibes/soul/sections/cart/schema';
@@ -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
@@ -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 { getTranslations } from 'next-intl/server';
7+
import { unstable_rethrow } from 'next/navigation';
78
import { ReactNode } from 'react';
89

910
import { compareAddToCartFormDataSchema } from '@/vibes/soul/primitives/compare-card/schema';
@@ -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
@@ -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 { getTranslations } from 'next-intl/server';
7+
import { unstable_rethrow } from 'next/navigation';
78
import { ReactNode } from 'react';
89

910
import { Field, schema } from '@/vibes/soul/sections/product-detail/schema';
@@ -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

core/app/[locale]/(default)/product/[slug]/_actions/wishlist-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SubmissionResult } from '@conform-to/react';
99
import { parseWithZod } from '@conform-to/zod';
1010
import { revalidateTag } from 'next/cache';
1111
import { getLocale, getTranslations } from 'next-intl/server';
12+
import { unstable_rethrow } from 'next/navigation';
1213
import { z } from 'zod';
1314

1415
import { CreateWishlistMutation } from '~/app/[locale]/(default)/account/wishlists/_actions/mutation';
@@ -237,6 +238,8 @@ export async function wishlistAction(payload: FormData): Promise<void> {
237238

238239
revalidateTag(TAGS.customer);
239240
} catch (error) {
241+
unstable_rethrow(error);
242+
240243
// eslint-disable-next-line no-console
241244
console.error(error);
242245

0 commit comments

Comments
 (0)