Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`Section1 Component matches snapshot 1`] = `
alt=""
src="/assets/img/icons/calender1.svg"
/>
15th, 16th, & 17th January “2025”
15th, 16th, & 17th January “2025”
</a>
</li>
</ul>
Expand Down
93 changes: 55 additions & 38 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,55 +28,72 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
});
}

for (const year of years) {
urls.push({
url: `${baseUrl}/${year}`,
lastModified: new Date(),
changeFrequency: "daily",
priority: 0.9,
});
/*
* ⚡ Bolt Performance Optimization
* Replaced sequential year-by-year O(N) fetching with parallel Promise.all.
* Also running getSpeakers and getTalks concurrently within each year.
* This changes the data fetching from O(years * 2) sequential await calls to O(1) concurrent calls,
* significantly reducing the total time required for sitemap generation.
Comment on lines +35 to +36
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 complexity analysis in this comment could be misleading. While the change is a great performance improvement, describing it as O(1) concurrent calls isn't standard. It's more accurate to say that you're moving from a sequential process to a parallel one, executing requests for all years concurrently. This could be rephrased for clarity.

Suggested change
* This changes the data fetching from O(years * 2) sequential await calls to O(1) concurrent calls,
* significantly reducing the total time required for sitemap generation.
* This changes the data fetching from a sequential process over N years to a single batch of parallel requests,
* significantly reducing the total time required for sitemap generation.

*/
const yearDataResults = await Promise.all(
years.map(async (year) => {
const yearUrls: MetadataRoute.Sitemap = [];

const yearPages = ["speakers", "talks", "schedule", "job-offers", "cfp", "diversity", "sponsorship", "travel"];
for (const page of yearPages) {
urls.push({
url: `${baseUrl}/${year}/${page}`,
yearUrls.push({
url: `${baseUrl}/${year}`,
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.8,
changeFrequency: "daily",
priority: 0.9,
});
}

const speakers = await getSpeakers(year);
for (const speaker of speakers) {
urls.push({
url: `${baseUrl}/${year}/speakers/${speaker.id}`,
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.7,
});
}
const yearPages = ["speakers", "talks", "schedule", "job-offers", "cfp", "diversity", "sponsorship", "travel"];
for (const page of yearPages) {
yearUrls.push({
url: `${baseUrl}/${year}/${page}`,
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.8,
});
}

const [speakers, sessionGroups] = await Promise.all([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.

⚠️ Potential issue | 🟡 Minor

Silent error swallowing violates error handling guidelines.

The .catch(() => []) pattern silently discards errors without logging. While getSpeakers and getTalks have internal error handling, unexpected rejections at the promise level would be silently swallowed here.

🛡️ Proposed fix with logging
-      const [speakers, sessionGroups] = await Promise.all([getSpeakers(year).catch(() => []), getTalks(year).catch(() => [])]);
+      const [speakers, sessionGroups] = await Promise.all([
+        getSpeakers(year).catch((error) => {
+          console.error(`Sitemap: Failed to fetch speakers for ${year}:`, error);
+          return [];
+        }),
+        getTalks(year).catch((error) => {
+          console.error(`Sitemap: Failed to fetch talks for ${year}:`, error);
+          return [];
+        }),
+      ]);

As per coding guidelines: "Do not use generic catch-all statements without logging or handling the error properly."

📝 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
const [speakers, sessionGroups] = await Promise.all([getSpeakers(year).catch(() => []), getTalks(year).catch(() => [])]);
const [speakers, sessionGroups] = await Promise.all([
getSpeakers(year).catch((error) => {
console.error(`Sitemap: Failed to fetch speakers for ${year}:`, error);
return [];
}),
getTalks(year).catch((error) => {
console.error(`Sitemap: Failed to fetch talks for ${year}:`, error);
return [];
}),
]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/sitemap.ts` at line 59, The Promise.all call currently swallows errors
with .catch(() => []) for getSpeakers and getTalks; remove the silent catches
and instead handle rejections by logging the error (using the existing logger,
e.g., processLogger or console.error) and then returning an empty array as a
safe fallback, so change the Promise.all invocation that references
getSpeakers(year) and getTalks(year) to await the promises without silent
catches and add proper catch handlers that log the error and return [] for each
function.


const sessionGroups = await getTalks(year);
for (const group of sessionGroups) {
for (const talk of group.sessions) {
urls.push({
url: `${baseUrl}/${year}/talks/${talk.id}`,
for (const speaker of speakers) {
yearUrls.push({
url: `${baseUrl}/${year}/speakers/${speaker.id}`,
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.7,
});
}
}

const companies = getJobOffersByYear(year);
for (const company of companies) {
urls.push({
url: `${baseUrl}/${year}/job-offers/${slugify(company.name)}`,
lastModified: new Date(),
changeFrequency: "monthly",
priority: 0.5,
});
}
for (const group of sessionGroups) {
for (const talk of group.sessions) {
yearUrls.push({
url: `${baseUrl}/${year}/talks/${talk.id}`,
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.7,
});
}
}

const companies = getJobOffersByYear(year);
for (const company of companies) {
yearUrls.push({
url: `${baseUrl}/${year}/job-offers/${slugify(company.name)}`,
lastModified: new Date(),
changeFrequency: "monthly",
priority: 0.5,
});
}

return yearUrls;
})
);

for (const yearUrls of yearDataResults) {
urls.push(...yearUrls);
}

return urls;
Comment on lines +95 to 99
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

This block of code can be simplified to a single line. Using Array.prototype.flat() will flatten the nested arrays of URLs, and Array.prototype.concat() can be used to create and return a new array with all the URLs. This approach is more concise and avoids mutating the urls array directly in this step.

  return urls.concat(yearDataResults.flat());

Expand Down
Loading
Loading