-
Notifications
You must be signed in to change notification settings - Fork 0
feat: [performance improvement] Parallelize generateStaticParams fetching #253
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 |
|---|---|---|
|
|
@@ -20,20 +20,20 @@ interface SpeakerDetailProps { | |
|
|
||
| export async function generateStaticParams() { | ||
| const years = getArchivedEditions(); | ||
| const params = []; | ||
|
|
||
| for (const year of years) { | ||
| try { | ||
| const speakers = await getSpeakers(year); | ||
| for (const speaker of speakers) { | ||
| params.push({ year, speakerId: speaker.id }); | ||
| const paramsArrays = await Promise.all( | ||
| years.map(async (year) => { | ||
| try { | ||
| const speakers = await getSpeakers(year); | ||
| return speakers.map((speaker) => ({ year, speakerId: speaker.id })); | ||
| } catch (error) { | ||
| console.warn(`Failed to fetch speakers for year ${year}:`, error); | ||
| return []; | ||
| } | ||
| } catch (error) { | ||
| console.warn(`Failed to fetch speakers for year ${year}:`, error); | ||
| } | ||
| } | ||
| }) | ||
| ); | ||
|
Comment on lines
+24
to
+34
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 should include a 'strict' mode that throws an error on failure to ensure that data fetching problems cause the build to fail, preventing the deployment of incomplete pages. Currently, References
|
||
|
|
||
| return params; | ||
| return paramsArrays.flat(); | ||
| } | ||
|
|
||
| export async function generateMetadata({ params }: SpeakerDetailProps): Promise<Metadata> { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,27 +18,30 @@ export const dynamicParams = false; | |
|
|
||
| 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); | ||
| const allTags = new Set<string>(); | ||
|
|
||
| for (const talk of allTalks) { | ||
| getTagsFromTalk(talk).forEach((tag) => allTags.add(tag)); | ||
| } | ||
|
|
||
| for (const tag of allTags) { | ||
| params.push({ year, tag: tag.replaceAll(" ", "-").toLowerCase() }); | ||
| const paramsArrays = await Promise.all( | ||
| years.map(async (year) => { | ||
| try { | ||
| const sessionGroups = await getTalks(year); | ||
| const allTalks = sessionGroups.flatMap((group) => group.sessions); | ||
| const allTags = new Set<string>(); | ||
|
|
||
| for (const talk of allTalks) { | ||
| getTagsFromTalk(talk).forEach((tag) => allTags.add(tag)); | ||
| } | ||
|
|
||
| return Array.from(allTags).map((tag) => ({ | ||
| year, | ||
| tag: tag.replaceAll(" ", "-").toLowerCase(), | ||
| })); | ||
| } 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
+22
to
+42
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 should include a 'strict' mode that throws an error on failure to ensure that data fetching problems cause the build to fail, preventing the deployment of incomplete pages. Currently, References
|
||
|
|
||
| return params; | ||
| return paramsArrays.flat(); | ||
| } | ||
|
|
||
| export async function generateMetadata({ params }: Readonly<TagPageProps>): Promise<Metadata> { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,21 +30,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 paramsArrays = 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
+45
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 should include a 'strict' mode that throws an error on failure to ensure that data fetching problems cause the build to fail, preventing the deployment of incomplete pages. Currently, References
|
||
|
|
||
| return params; | ||
| return paramsArrays.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.
Update the action description to reflect the use of strict mode for build-critical data fetching, ensuring that any failures correctly fail the build to prevent deploying incomplete pages.