-
Notifications
You must be signed in to change notification settings - Fork 0
feat: [performance improvement] Parallelize data fetching in talks generateStaticParams #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,21 +29,21 @@ interface TalkDetailProps { | |
|
|
||
| export async function generateStaticParams() { | ||
| const years = getArchivedEditions(); | ||
| const params = []; | ||
|
|
||
| for (const year of years) { | ||
| try { | ||
| const sessionGroups = await getTalks(year); | ||
| const allTalks = sessionGroups.flatMap((group) => group.sessions); | ||
| for (const talk of allTalks) { | ||
| params.push({ year, talkId: talk.id }); | ||
|
|
||
| const nestedParams = await Promise.all( | ||
| years.map(async (year) => { | ||
| try { | ||
| const sessionGroups = await getTalks(year); | ||
| const allTalks = sessionGroups.flatMap((group) => group.sessions); | ||
| return allTalks.map((talk) => ({ year, talkId: talk.id })); | ||
| } catch (error) { | ||
| console.warn(`Failed to fetch talks for year ${year}:`, error); | ||
| return []; | ||
| } | ||
| } catch (error) { | ||
| console.warn(`Failed to fetch talks for year ${year}:`, error); | ||
| } | ||
| } | ||
| }) | ||
|
Comment on lines
+34
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the repository's general rules, data fetching functions used during the build process (such as References
|
||
| ); | ||
|
|
||
| return params; | ||
| return nestedParams.flat(); | ||
| } | ||
|
|
||
| export async function generateMetadata({ params }: TalkDetailProps): Promise<Metadata> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recommendation to 'always preserve per-item try/catch fallbacks to avoid failing the entire batch' contradicts the repository's general rule. For build-time data fetching, we want failures to halt the build so we do not deploy incomplete pages. Please update this documentation to recommend using strict mode for build-time data fetching.
References