-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
sw 2.3.5 cause LobeChat build failed while 2.3.4 not.
⚠ Using edge runtime on a page currently disables static generation for that page
Generating static pages (0/377) ...
Generating static pages (94/377)
Generating static pages (188/377)
Generating static pages (282/377)
Error occurred prerendering page "/en-US__0__dark/chat". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Fallback data is required when using Suspense in SSR.
at useSWRHandler (/vercel/path0/.next/server/chunks/30323.js:209816:19)
at /vercel/path0/.next/server/chunks/30323.js:281382:16
at useSWRArgs (/vercel/path0/.next/server/chunks/30323.js:281404:16)
at useFetchPluginStore (/vercel/path0/.next/server/chunks/24346.js:59621:92)
at useControls (/vercel/path0/.next/server/app/[variants]/(main)/chat/(workspace)/page.js:13895:5)
at /vercel/path0/.next/server/app/[variants]/(main)/chat/(workspace)/page.js:42509:85
at nF (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:76:46843)
at nH (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:76:48618)
at nH (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:76:64107)
at nW (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:76:67762)
Export encountered an error on /[variants]/(main)/chat/(workspace)/page: /en-US__0__dark/chat, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null
error: script "build" exited with code 1
Error: Command "bun run build" exited with 1
Description / Observed Behavior
we use swr with some code like this:
useFetchTopics: (enable, sessionId) =>
useClientDataSWR<ChatTopic[]>(
enable ? [SWR_USE_FETCH_TOPIC, sessionId] : null,
async ([, sessionId]: [string, string]) => topicService.getTopics({ sessionId }),
{
suspense: true,
fallbackData: [],
onSuccess: (topics) => {
const nextMap = { ...get().topicMaps, [sessionId]: topics };
// no need to update map if the topics have been init and the map is the same
if (get().topicsInit && isEqual(nextMap, get().topicMaps)) return;
set(
{ topicMaps: nextMap, topicsInit: true },
false,
n('useFetchTopics(success)', { sessionId }),
);
},
},
),
and it works fine with 2.3.4 but failed in next build with Prerender in 2.3.5.
here is the failing test action: https://github.com/lobehub/lobe-chat/actions/runs/16848284108/job/47731232183
Expected Behavior
build success with next like 2.3.4
Repro Steps / Code Example
-
git clone https://github.com/lobehub/lobe-chat
-
git checkout reproduction/swr-2.3.5
-
npm run build
it only failed with [email protected]
Additional Context
I have pin swr to 2.3.4 to fix the build temporarily lobehub/lobe-chat#8746
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working