Skip to content

feat: [performance improvement]#251

Open
anyulled wants to merge 2 commits into
mainfrom
bolt/parallel-generate-static-params-4612543585120995632
Open

feat: [performance improvement]#251
anyulled wants to merge 2 commits into
mainfrom
bolt/parallel-generate-static-params-4612543585120995632

Conversation

@anyulled
Copy link
Copy Markdown
Owner

@anyulled anyulled commented May 31, 2026

💡 What: Replaced the sequential for...of loops used for gathering dynamic data in generateStaticParams with parallel concurrent fetches using Promise.all(years.map(...)) and .flat() across app/[year]/job-offers/[companyName]/page.tsx, app/[year]/speakers/[speakerId]/page.tsx, app/[year]/tags/[tag]/page.tsx, and app/[year]/talks/[talkId]/page.tsx.

🎯 Why: Sequential data fetching inside Next.js build-time functions severely bottlenecked build generation, blocking the thread while waiting for individual years' HTTP requests to resolve one by one.

📊 Impact: Significantly reduces total Next.js static build execution time and duration by parallelizing the collection of parameters necessary to pre-render dynamic routes across all available edition years.

🔬 Measurement: Build completion duration can be accurately measured locally or via CI comparing npm run build total duration prior to and following this branch integration.


PR created automatically by Jules for task 4612543585120995632 started by @anyulled

Summary by CodeRabbit

  • Performance

    • Improved build performance for job offers, speakers, tags, and talks pages through more efficient static page generation.
  • Documentation

    • Added guidance on optimizing Next.js build-time workflows.

Replaced sequential `for...of` loops with `Promise.all(years.map(...))` in `generateStaticParams` across dynamic routes to improve Next.js build performance, properly un-nesting arrays using `.flat()` while preserving `try/catch` fallbacks.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
devbcn-nextjs Error Error May 31, 2026 8:34am

Request Review

@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Review Change Stack

Warning

Review limit reached

@anyulled, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 41 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52515825-52cd-4be5-a699-e625f3452317

📥 Commits

Reviewing files that changed from the base of the PR and between c83bd14 and 7cc3c3a.

📒 Files selected for processing (1)
  • .jules/bolt.md
📝 Walkthrough

Walkthrough

Refactored Next.js static parameter generation across four dynamic routes from sequential year iteration to concurrent Promise.all fetching. Each route now builds per-year parameter arrays in parallel and flattens the results while retaining per-year error handling with try/catch fallbacks.

Changes

Next.js Static Generation Parallelization

Layer / File(s) Summary
Parallelization pattern documentation
.jules/bolt.md
Added a dated learning note documenting the optimization pattern: replacing sequential for...of loops with Promise.all parallelization, aggregating results with .flat(), and preserving per-item try/catch error handling.
Dynamic route static params refactoring
app/[year]/job-offers/[companyName]/page.tsx, app/[year]/speakers/[speakerId]/page.tsx, app/[year]/tags/[tag]/page.tsx, app/[year]/talks/[talkId]/page.tsx
Refactored generateStaticParams() in all four routes to fetch and compute parameters concurrently across archived years using Promise.all(years.map(...)), construct per-year parameter arrays inside each promise, and return flattened results. Per-year error logging and fallback behavior preserved identical to previous sequential implementation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

size/M

🐰 Four routes now hop in parallel,
No more waiting year by year,
Build-time speeds up, results stay true,
Promise.all brings change that's clear!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat: [performance improvement]' is vague and generic, using a bracketed placeholder-style format that doesn't convey the specific nature of the changes (parallelizing static param generation). Replace the generic '[performance improvement]' with a specific descriptor like 'feat: parallelize static param generation' to clearly communicate the main change to reviewers scanning history.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt/parallel-generate-static-params-4612543585120995632

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request optimizes Next.js static generation builds by replacing sequential loops with parallel data fetching using Promise.all in generateStaticParams across multiple routes, and documents this practice in .jules/bolt.md. The review feedback points out that the added try/catch blocks are redundant because the data fetching functions do not throw unless strict mode is enabled. It recommends enabling strict mode to ensure build failures on data fetching errors, removing the try/catch blocks, simplifying the array mapping using .map(), and updating the documentation to reflect this strict mode requirement.

Comment on lines +24 to +37
const nestedParams = await Promise.all(
years.map(async (year) => {
const params: { year: string; speakerId: string }[] = [];
try {
const speakers = await getSpeakers(year);
for (const speaker of speakers) {
params.push({ year, speakerId: speaker.id });
}
} catch (error) {
console.warn(`Failed to fetch speakers for year ${year}:`, error);
}
} catch (error) {
console.warn(`Failed to fetch speakers for year ${year}:`, error);
}
}
return params;
})
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The try/catch block is currently dead code because getSpeakers(year) does not throw errors unless { strict: true } is passed. Furthermore, according to the repository's general rules, data fetching functions used during the build process should run in strict mode to ensure that failures cause the build to fail, preventing the deployment of incomplete pages.

We should pass { strict: true } to getSpeakers and let the error propagate (removing the try/catch block). We can also simplify the array mapping using .map() instead of a manual loop and .push().

  const nestedParams = await Promise.all(
    years.map(async (year) => {
      const speakers = await getSpeakers(year, { strict: true });
      return speakers.map((speaker) => ({
        year,
        speakerId: speaker.id,
      }));
    })
  );
References
  1. Data fetching functions used during the build process (e.g., for sitemap generation) should include a 'strict' mode that throws an error on failure. This ensures that data fetching problems cause the build to fail, preventing the deployment of incomplete pages.

Comment on lines +22 to +42
const nestedParams = await Promise.all(
years.map(async (year) => {
const params: { year: string; tag: string }[] = [];
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() });
}
} catch (error) {
console.warn(`Failed to fetch talks for year ${year}:`, error);
}
} catch (error) {
console.warn(`Failed to fetch talks for year ${year}:`, error);
}
}
return params;
})
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The try/catch block is currently dead code because getTalks(year) does not throw errors unless { strict: true } is passed. Furthermore, according to the repository's general rules, data fetching functions used during the build process should run in strict mode to ensure that failures cause the build to fail, preventing the deployment of incomplete pages.

We should pass { strict: true } to getTalks and let the error propagate (removing the try/catch block). We can also simplify the array mapping using .map() instead of a manual loop and .push().

  const nestedParams = await Promise.all(
    years.map(async (year) => {
      const sessionGroups = await getTalks(year, { strict: true });
      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(),
      }));
    })
  );
References
  1. Data fetching functions used during the build process (e.g., for sitemap generation) should include a 'strict' mode that throws an error on failure. This ensures that data fetching problems cause the build to fail, preventing the deployment of incomplete pages.

Comment on lines +33 to +47
const nestedParams = await Promise.all(
years.map(async (year) => {
const params: { year: string; talkId: string }[] = [];
try {
const sessionGroups = await getTalks(year);
const allTalks = sessionGroups.flatMap((group) => group.sessions);
for (const talk of allTalks) {
params.push({ year, talkId: talk.id });
}
} catch (error) {
console.warn(`Failed to fetch talks for year ${year}:`, error);
}
} catch (error) {
console.warn(`Failed to fetch talks for year ${year}:`, error);
}
}
return params;
})
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The try/catch block is currently dead code because getTalks(year) does not throw errors unless { strict: true } is passed. Furthermore, according to the repository's general rules, data fetching functions used during the build process should run in strict mode to ensure that failures cause the build to fail, preventing the deployment of incomplete pages.

We should pass { strict: true } to getTalks and let the error propagate (removing the try/catch block). We can also simplify the array mapping using .map() instead of a manual loop and .push().

  const nestedParams = await Promise.all(
    years.map(async (year) => {
      const sessionGroups = await getTalks(year, { strict: true });
      const allTalks = sessionGroups.flatMap((group) => group.sessions);
      return allTalks.map((talk) => ({
        year,
        talkId: talk.id,
      }));
    })
  );
References
  1. Data fetching functions used during the build process (e.g., for sitemap generation) should include a 'strict' mode that throws an error on failure. This ensures that data fetching problems cause the build to fail, preventing the deployment of incomplete pages.

Comment thread .jules/bolt.md

## 2024-05-31 - Optimize Next.js static generation builds with parallel data fetching
**Learning:** Sequential `for...of` loops used for fetching dynamic page dependencies inside Next.js build-time functions like `generateStaticParams` (or `sitemap.ts`) block the thread and significantly increase total site build duration.
**Action:** When gathering parameters for static routes across large array sets (such as mapping years or categories), replace sequential `for...of` iteration with parallel execution using `Promise.all(array.map(...))`. Then, correctly aggregate nested outputs utilizing `.flat()` or `.flatMap()`, and preserve per-item `try/catch` fallbacks to prevent a single item failure from crashing the entire batch build.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The recommendation to 'preserve per-item try/catch fallbacks to prevent a single item failure from crashing the entire batch build' contradicts the repository's general rule. We want data fetching failures during the build process to fail the build so that we do not deploy incomplete pages. Let's update this documentation to reflect the correct practice.

Suggested change
**Action:** When gathering parameters for static routes across large array sets (such as mapping years or categories), replace sequential `for...of` iteration with parallel execution using `Promise.all(array.map(...))`. Then, correctly aggregate nested outputs utilizing `.flat()` or `.flatMap()`, and preserve per-item `try/catch` fallbacks to prevent a single item failure from crashing the entire batch build.
**Action:** When gathering parameters for static routes across large array sets (such as mapping years or categories), replace sequential `for...of` iteration with parallel execution using `Promise.all(array.map(...))`. Then, correctly aggregate nested outputs utilizing `.flat()` or `.flatMap()`, and ensure data fetching functions run in strict mode without swallowing errors to let failures correctly fail the build and prevent deploying incomplete pages.
References
  1. Data fetching functions used during the build process (e.g., for sitemap generation) should include a 'strict' mode that throws an error on failure. This ensures that data fetching problems cause the build to fail, preventing the deployment of incomplete pages.

Comment on lines +24 to +36
const nestedParams = await Promise.all(
years.map(async (year) => {
const params: { year: string; companyName: string }[] = [];
const companies = await getJobOffersForEdition(year);
for (const company of companies) {
params.push({
year,
companyName: company.id,
});
}
return params;
})
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Simplify the nested mapping using .map() instead of initializing an empty array and manually pushing to it. Additionally, to fully align with the repository's general rules, getJobOffersForEdition should ideally be updated to support a strict mode that throws on failure, though that can be addressed in a separate PR since public-queries.ts is not modified here.

  const nestedParams = await Promise.all(
    years.map(async (year) => {
      const companies = await getJobOffersForEdition(year);
      return companies.map((company) => ({
        year,
        companyName: company.id,
      }));
    })
  );

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/[year]/job-offers/[companyName]/page.tsx (1)

24-38: ⚡ Quick win

Add per-year error isolation in Promise.all mapping.

A single unexpected rejection currently aborts all static params generation. Catch per year and return [] to keep the build resilient.

Proposed patch
   const nestedParams = await Promise.all(
     years.map(async (year) => {
       const params: { year: string; companyName: string }[] = [];
-      const companies = await getJobOffersForEdition(year);
-      for (const company of companies) {
-        params.push({
-          year,
-          companyName: company.id,
-        });
+      try {
+        const companies = await getJobOffersForEdition(year);
+        for (const company of companies) {
+          params.push({
+            year,
+            companyName: company.id,
+          });
+        }
+      } catch (error) {
+        console.warn(`Failed to fetch job offers for year ${year}:`, error);
       }
       return params;
     })
   );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/`[year]/job-offers/[companyName]/page.tsx around lines 24 - 38, The
Promise.all over years currently lets any rejection abort the whole static
params generation; wrap the per-year async mapper used in years.map (the
function that calls getJobOffersForEdition and builds params, assigned to
nestedParams) in a try/catch so that errors for a single year are caught and the
mapper returns an empty array [] on failure; keep logging or process the error
inside the catch for visibility but ensure the mapper never throws so
nestedParams.flat() completes resiliently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/`[year]/job-offers/[companyName]/page.tsx:
- Around line 24-38: The Promise.all over years currently lets any rejection
abort the whole static params generation; wrap the per-year async mapper used in
years.map (the function that calls getJobOffersForEdition and builds params,
assigned to nestedParams) in a try/catch so that errors for a single year are
caught and the mapper returns an empty array [] on failure; keep logging or
process the error inside the catch for visibility but ensure the mapper never
throws so nestedParams.flat() completes resiliently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53276fbf-81a1-4e11-a2f0-970d12528306

📥 Commits

Reviewing files that changed from the base of the PR and between 302d751 and c83bd14.

📒 Files selected for processing (5)
  • .jules/bolt.md
  • app/[year]/job-offers/[companyName]/page.tsx
  • app/[year]/speakers/[speakerId]/page.tsx
  • app/[year]/tags/[tag]/page.tsx
  • app/[year]/talks/[talkId]/page.tsx

Replaced sequential `for...of` loops with `Promise.all(years.map(...))` in `generateStaticParams` across dynamic routes to improve Next.js build performance, properly un-nesting arrays using `.flat()` while preserving `try/catch` fallbacks.
Fixed Prettier formatting on `.jules/bolt.md` to pass CI.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant