Skip to content

feat: [performance improvement] Parallelize data fetching in talks generateStaticParams#252

Open
anyulled wants to merge 2 commits into
mainfrom
bolt/perf-talks-static-params-13649902803938676347
Open

feat: [performance improvement] Parallelize data fetching in talks generateStaticParams#252
anyulled wants to merge 2 commits into
mainfrom
bolt/perf-talks-static-params-13649902803938676347

Conversation

@anyulled
Copy link
Copy Markdown
Owner

@anyulled anyulled commented Jun 1, 2026

💡 What: Replaced sequential loop with Promise.all + Array.map to fetch getTalks concurrently.
🎯 Why: Sequential awaits block data fetching across years, unnecessarily increasing build time.
📊 Impact: O(N) reduction in build time blockages for this route (relative to number of editions).
🔬 Measurement: Observe improved next build static page generation times for /[year]/talks/[talkId].


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

Summary by CodeRabbit

  • Documentation

    • Added build performance guidance covering optimization techniques for array operations and static page generation workflows.
  • Performance

    • Optimized static page generation through concurrent data fetching for improved build efficiency.

…nerateStaticParams

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 Jun 1, 2026

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

Project Deployment Actions Updated (UTC)
devbcn-nextjs Error Error Jun 1, 2026 8:49am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 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 54 minutes and 54 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: 0ac1489b-04e5-465c-84ea-264ff09d02be

📥 Commits

Reviewing files that changed from the base of the PR and between 8373f06 and 91a8bc3.

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

Walkthrough

This PR documents and implements a build-performance optimization that replaces sequential fetching in generateStaticParams with concurrent Promise.all calls across archived years. The code refactors parameter generation to fetch talks in parallel while preserving per-year error handling.

Changes

Build Performance Optimization

Layer / File(s) Summary
Parallelize generateStaticParams with Promise.all
.jules/bolt.md, app/[year]/talks/[talkId]/page.tsx
Documentation adds guidance on replacing sequential for...of fetching with Promise.all and related Map-based patterns. generateStaticParams refactors to fetch talks for all years concurrently, mapping each to its { year, talkId } pairs, catching per-year errors, and flattening nested results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

size/M

Poem

🐰 A rabbit hops through years so fast,
With Promise.all no fetches last,
Concurrent dreams in nested arrays,
Build times shrink through parallelways—
Faster generation, hop hooray! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: parallelizing data fetching in the talks generateStaticParams function, which is the primary optimization detailed in the changeset.
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/perf-talks-static-params-13649902803938676347

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.

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Parallelize data fetching in talks generateStaticParams

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Parallelize concurrent data fetching in generateStaticParams
• Replace sequential for...of loop with Promise.all
• Reduce build time from O(N) sequential to concurrent execution
• Document performance learning and best practices
Diagram
flowchart LR
  A["Sequential for...of loop"] -->|"getTalks awaits block"| B["O(N) build time"]
  C["Promise.all with map"] -->|"concurrent fetches"| D["Optimized build time"]
  B -->|"refactored to"| D

Loading

Grey Divider

File Changes

1. .jules/bolt.md 📝 Documentation +4/-0

Document performance learning for concurrent fetching

• Added learning note about generateStaticParams sequential fetch bottleneck
• Documented action to use Promise.all with Array.map for concurrent requests
• Included guidance on preserving per-item error handling in batch operations

.jules/bolt.md


2. app/[year]/talks/[talkId]/page.tsx ✨ Enhancement +13/-13

Parallelize concurrent talk data fetching in generateStaticParams

• Replaced sequential for...of loop with await Promise.all(years.map(async ...))
• Changed nested loop structure to use flatMap within map callback
• Preserved per-year error handling with try/catch fallback returning empty array
• Flattened nested array result with .flat() before returning params

app/[year]/talks/[talkId]/page.tsx


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Jun 1, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

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 parallelizes the data fetching inside generateStaticParams using Promise.all to improve build performance, and documents this practice in .jules/bolt.md. Feedback highlights that swallowing errors with a try/catch block during build-time data fetching violates the rule of using strict mode to fail the build on failures. Both the implementation and the documentation should be updated to enforce strict mode and prevent silent build successes with incomplete data.

Comment on lines +34 to +43
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);
}
}
})
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

According to the repository's general rules, data fetching functions used during the build process (such as generateStaticParams) should run in strict mode. This ensures that any data fetching failure correctly halts the build, preventing the deployment of incomplete pages with missing talks. Swallowing the error and returning an empty array allows the build to succeed silently with incomplete data.

    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-19 - Parallelize next build generateStaticParams

**Learning:** When `generateStaticParams` uses a sequential `for...of` loop to iterate over multiple parameters (like event years) and fetches external data, it forces Next.js to wait sequentially for each fetch to finish before starting the next. This creates a significant, O(N) performance bottleneck during the build step.
**Action:** Replace sequential `for...of` loops with `await Promise.all(items.map(async (item) => { ... }))`. By mapping each item into an async data-fetching promise, Next.js executes the requests concurrently, resulting in significantly faster build times. Always make sure to preserve per-item `try/catch` fallbacks to avoid failing the entire batch if a single item errors.
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 '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
  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.

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.jules/bolt.md (1)

1-9: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Address the Prettier formatting issue.

The CI pipeline flagged formatting issues in this file. Run prettier --write .jules/bolt.md to resolve.

🤖 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 @.jules/bolt.md around lines 1 - 9, Run Prettier to fix the formatting of the
markdown file flagged by CI: format ".jules/bolt.md" using your project's
formatter (e.g., run prettier --write .jules/bolt.md or the repo's format
script), verify the file format changes, and commit the updated file so the
pipeline passes.
🧹 Nitpick comments (1)
app/[year]/talks/[talkId]/page.tsx (1)

33-44: Consider monitoring concurrent fetch behavior.

The refactor correctly parallelizes fetching across all archived years, but if getArchivedEditions() returns a large number of years, the concurrent Promise.all may send many simultaneous requests to the external service. Depending on the service's rate limits or capacity, you may want to:

  • Monitor build logs for rate-limit errors
  • Consider batching with a concurrency limit (e.g., using Promise.all on chunks) if issues arise
  • Verify that the external service can handle the concurrent load during builds
🤖 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]/talks/[talkId]/page.tsx around lines 33 - 44, The current
nestedParams assembly uses Promise.all over years which may issue many
simultaneous requests; limit concurrency by replacing the direct
Promise.all(years.map(...)) pattern used around getTalks with a batched or
throttled approach (e.g., process years in chunks or use a concurrency-limited
runner) so nestedParams computation still maps year -> ({ year, talkId }) but
only runs a bounded number of getTalks calls in parallel; update the block that
defines nestedParams and the inner async mapping (references: nestedParams,
years, getTalks, sessionGroups, allTalks) to implement batching or a concurrency
limiter and keep the existing error handling for each year.
🤖 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.

Outside diff comments:
In @.jules/bolt.md:
- Around line 1-9: Run Prettier to fix the formatting of the markdown file
flagged by CI: format ".jules/bolt.md" using your project's formatter (e.g., run
prettier --write .jules/bolt.md or the repo's format script), verify the file
format changes, and commit the updated file so the pipeline passes.

---

Nitpick comments:
In `@app/`[year]/talks/[talkId]/page.tsx:
- Around line 33-44: The current nestedParams assembly uses Promise.all over
years which may issue many simultaneous requests; limit concurrency by replacing
the direct Promise.all(years.map(...)) pattern used around getTalks with a
batched or throttled approach (e.g., process years in chunks or use a
concurrency-limited runner) so nestedParams computation still maps year -> ({
year, talkId }) but only runs a bounded number of getTalks calls in parallel;
update the block that defines nestedParams and the inner async mapping
(references: nestedParams, years, getTalks, sessionGroups, allTalks) to
implement batching or a concurrency limiter and keep the existing error handling
for each year.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: edccba87-92ba-4b2b-867d-588d8526f00d

📥 Commits

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

📒 Files selected for processing (2)
  • .jules/bolt.md
  • app/[year]/talks/[talkId]/page.tsx

…nerateStaticParams

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