Skip to content

⚡ Bolt: Parallelize sitemap generation across years#135

Open
anyulled wants to merge 1 commit intomainfrom
bolt-optimize-sitemap-parallel-17554748619876484985
Open

⚡ Bolt: Parallelize sitemap generation across years#135
anyulled wants to merge 1 commit intomainfrom
bolt-optimize-sitemap-parallel-17554748619876484985

Conversation

@anyulled
Copy link
Copy Markdown
Owner

@anyulled anyulled commented Mar 30, 2026

💡 What: Refactored the sitemap generation in app/sitemap.ts to use Promise.all across the years array, allowing data fetching for speakers and talks to happen in parallel for all available years rather than sequentially in a for...of loop.

🎯 Why: Previously, the sitemap generated URLs by iterating over each year in sequence and awaiting API calls. This created a significant "waterfall" effect, where the data fetch for 2024 wouldn't begin until 2023 finished. In environments like Next.js App Router static generation, this creates unnecessary build latency.

📊 Impact: Reduces sitemap generation time linearly relative to the number of conference years. By fetching all data in parallel, the total wait time is approximately equal to the single slowest request across all years, instead of the sum of all requests.

🔬 Measurement: You can verify the improvement by running a production build (npm run build) and observing the time taken to generate the /sitemap.xml route before and after this change.


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

Summary by CodeRabbit

  • Chores
    • Optimized sitemap generation process for improved performance and enhanced error resilience during data retrieval.

Replaced sequential await for...of loops over years with Promise.all to fetch session groups and speakers for each year concurrently, reducing build-time waterfalls and speeding up sitemap generation.

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 Mar 30, 2026

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

Project Deployment Actions Updated (UTC)
devbcn Ready Ready Preview, Comment Mar 30, 2026 9:08am

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 sitemap generation by parallelizing data fetching across multiple years and concurrently retrieving speakers and talks. It also includes a minor whitespace correction in a test snapshot. Feedback suggests improving observability by logging errors when data fetching fails and simplifying the array flattening logic using the .flat() method.

Comment on lines +56 to +57
getSpeakers(year).catch(() => []),
getTalks(year).catch(() => []),
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

Silently catching errors with .catch(() => []) can hide potential issues. If getSpeakers or getTalks were ever to change and start throwing errors, those errors would be swallowed without any logs, making debugging difficult. It's better to log the error before returning the default value. While getSpeakers and getTalks currently handle errors internally, this change makes the sitemap generation more robust against future changes to those functions.

      getSpeakers(year).catch((err) => {
        console.error(`Error fetching speakers for sitemap (year: ${year}):`, err);
        return [];
      }),
      getTalks(year).catch((err) => {
        console.error(`Error fetching talks for sitemap (year: ${year}):`, err);
        return [];
      })

Comment on lines +94 to 96
for (const yearUrls of yearUrlsArrays) {
urls.push(...yearUrls);
}
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

You can simplify the logic for flattening the array of URL arrays by using Array.prototype.flat(). This is more concise and readable than a for...of loop.

  urls.push(...yearUrlsArrays.flat());

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

The sitemap generation in app/sitemap.ts is refactored from sequential year-by-year processing to parallel processing. Each year's speakers and talks are now fetched concurrently via Promise.all, and all years are processed in parallel, with error suppression added via .catch(() => []) to substitute empty arrays on failure.

Changes

Cohort / File(s) Summary
Sitemap year processing parallelization
app/sitemap.ts
Converted sequential year loop to parallel processing using Promise.all() for year iteration. Per-year data fetching (getSpeakers and getTalks) now runs concurrently rather than sequentially. Added error suppression with .catch(() => []) to handle failures gracefully. URL building restructured to use per-year arrays that are flattened after all promises resolve.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Hops now in parallel, no more one-by-one,
Fetching speakers and talks beneath the digital sun—
Promise.all the years, let the errors just fade,
A sitemap that's snappy? This rabbit's parade! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main optimization: parallelizing sitemap generation across years, which matches the core refactoring in app/sitemap.ts.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-optimize-sitemap-parallel-17554748619876484985

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

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/sitemap.ts`:
- Around line 54-58: The Promise.all call wraps getSpeakers(year) and
getTalks(year) with outer .catch(() => []) handlers that swallow errors without
logging; remove those outer .catch wrappers so that getSpeakers and getTalks
handle/log errors themselves and the Promise.all stays as
Promise.all([getSpeakers(year), getTalks(year)]) returning [speakers,
sessionGroups]; locate the Promise.all invocation where getSpeakers and getTalks
are called and delete the .catch(() => []) for each call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 00077ddb-0aea-4a1d-9960-6fdeb777ee5c

📥 Commits

Reviewing files that changed from the base of the PR and between 76a14e4 and b46c496.

⛔ Files ignored due to path filters (1)
  • __tests__/snapshots/sections/home10/__snapshots__/Section1.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • app/sitemap.ts

Comment on lines +54 to +58
// Parallel fetch speakers and talks for the given year, and catch errors to prevent partial failures from breaking the whole build
const [speakers, sessionGroups] = await Promise.all([
getSpeakers(year).catch(() => []),
getTalks(year).catch(() => []),
]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

fd -t f -name "useSpeakers.ts" -o -name "useTalks.ts"

Repository: anyulled/devbcn-nextjs

Length of output: 296


🏁 Script executed:

git ls-files | grep -E "(hooks|lib)" | head -20

Repository: anyulled/devbcn-nextjs

Length of output: 694


🏁 Script executed:

cat -n hooks/useSpeakers.ts

Repository: anyulled/devbcn-nextjs

Length of output: 1960


🏁 Script executed:

cat -n hooks/useTalks.ts

Repository: anyulled/devbcn-nextjs

Length of output: 5581


🏁 Script executed:

cat -n app/sitemap.ts | sed -n '50,65p'

Repository: anyulled/devbcn-nextjs

Length of output: 709


🏁 Script executed:

head -10 app/sitemap.ts

Repository: anyulled/devbcn-nextjs

Length of output: 486


Remove the outer catch-all wrappers that lack logging.

getSpeakers and getTalks already catch, log, and return [] in their implementations. The outer .catch(() => []) handlers in sitemap.ts lack logging and violate the guideline: "Avoid unhandled promise rejections. Do not use generic catch-all statements without logging or handling the error properly."

✂️ Proposed fix
-    const [speakers, sessionGroups] = await Promise.all([
-      getSpeakers(year).catch(() => []),
-      getTalks(year).catch(() => []),
-    ]);
+    const [speakers, sessionGroups] = await Promise.all([
+      getSpeakers(year),
+      getTalks(year),
+    ]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Parallel fetch speakers and talks for the given year, and catch errors to prevent partial failures from breaking the whole build
const [speakers, sessionGroups] = await Promise.all([
getSpeakers(year).catch(() => []),
getTalks(year).catch(() => []),
]);
// Parallel fetch speakers and talks for the given year, and catch errors to prevent partial failures from breaking the whole build
const [speakers, sessionGroups] = await Promise.all([
getSpeakers(year),
getTalks(year),
]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/sitemap.ts` around lines 54 - 58, The Promise.all call wraps
getSpeakers(year) and getTalks(year) with outer .catch(() => []) handlers that
swallow errors without logging; remove those outer .catch wrappers so that
getSpeakers and getTalks handle/log errors themselves and the Promise.all stays
as Promise.all([getSpeakers(year), getTalks(year)]) returning [speakers,
sessionGroups]; locate the Promise.all invocation where getSpeakers and getTalks
are called and delete the .catch(() => []) for each call.

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