From cd071ccae12942a50226b54f671a1e9644a9d2e3 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 3 Jun 2022 04:26:55 +0800 Subject: [PATCH] client: catch error --- .../client/src/services/server-prefetcher.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/client/src/services/server-prefetcher.ts b/packages/client/src/services/server-prefetcher.ts index a5e0383..b8a1fe5 100644 --- a/packages/client/src/services/server-prefetcher.ts +++ b/packages/client/src/services/server-prefetcher.ts @@ -14,15 +14,19 @@ export async function serverPrefetcher(ctx: NextPageContext, actions: PrefetchAc return {}; } - const queryClient = new QueryClient(); + try { + const queryClient = new QueryClient(); - await Promise.all( - actions.map((action) => { - return queryClient.prefetchQuery(action.url, () => action.action(cookie)); - }) - ); + await Promise.all( + actions.map((action) => { + return queryClient.prefetchQuery(action.url, () => action.action(cookie)); + }) + ); - return { - dehydratedState: dehydrate(queryClient), - }; + return { + dehydratedState: dehydrate(queryClient), + }; + } catch (err) { + return {}; + } }