Skip to content

Conversation

@boykisserchan
Copy link
Collaborator

  • no pii for you :trolley:
  • bleh
  • i am bad at coding
  • start caching rsvps and move to local api for fast data
  • why wasn't this commited?
  • Update rsvp.ts
  • Update RSVP.tsx
  • rsvp work
  • update subtitle
  • throw error to catch
  • security :thumbup:
  • Update src/pages/api/rsvp.ts
  • Apply suggestion from @copilot
  • install :3
  • something something return the erorr
  • refactor: update ButtonProps to use ReactNode type for children
  • feat: implement background cache updater for RSVP count

@vercel
Copy link

vercel bot commented Nov 5, 2025

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

Project Deployment Preview Comments Updated (UTC)
aces Ready Ready Preview Comment Nov 6, 2025 4:39am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Charmunks
Copy link
Member

lgtm

@boykisserchan boykisserchan requested a review from Copilot November 5, 2025 16:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeninh
Copy link
Collaborator

jeninh commented Nov 5, 2025

lgtm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let cached: Cache = { value: null, updated: 0 };

// Default cache duration 30 seconds; can be overridden with env var (ms)
const CACHE_DURATION_MS = Number(process.env.RSVP_CACHE_DURATION_MS) || 30_000;
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

Using Number() on an undefined or empty string environment variable returns NaN, not a falsy value. This means the || fallback won't work as expected. Use parseInt() with a radix or check for NaN explicitly: parseInt(process.env.RSVP_CACHE_DURATION_MS || '30000', 10) or Number(process.env.RSVP_CACHE_DURATION_MS) || 30_000 should be (Number(process.env.RSVP_CACHE_DURATION_MS) || 30_000) with parentheses, but better is: const parsed = parseInt(process.env.RSVP_CACHE_DURATION_MS ?? '', 10); const CACHE_DURATION_MS = isNaN(parsed) ? 30_000 : parsed;

Suggested change
const CACHE_DURATION_MS = Number(process.env.RSVP_CACHE_DURATION_MS) || 30_000;
const parsedCacheDuration = parseInt(process.env.RSVP_CACHE_DURATION_MS ?? '', 10);
const CACHE_DURATION_MS = isNaN(parsedCacheDuration) ? 30_000 : parsedCacheDuration;

Copilot uses AI. Check for mistakes.
Comment on lines 61 to 67
// initial immediate update (fire-and-forget)
updateCache().catch((e) => console.error("[rsvp] initial update failed:", e));

// schedule periodic updates
global.__RSVP_CACHE_TIMER__ = setInterval(() => {
updateCache().catch((e) => console.error("[rsvp] scheduled update failed:", e));
}, CACHE_DURATION_MS);
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

The module-level initialization code creates a race condition. If multiple requests arrive simultaneously before global.__RSVP_CACHE_TIMER__ is set (line 65), multiple intervals could be created. The timer assignment should happen immediately: global.__RSVP_CACHE_TIMER__ = true; (or a placeholder) before line 62, then reassign to the actual interval on line 65, or use a synchronous check-and-set pattern.

Suggested change
// initial immediate update (fire-and-forget)
updateCache().catch((e) => console.error("[rsvp] initial update failed:", e));
// schedule periodic updates
global.__RSVP_CACHE_TIMER__ = setInterval(() => {
updateCache().catch((e) => console.error("[rsvp] scheduled update failed:", e));
}, CACHE_DURATION_MS);
// Claim the timer slot immediately to prevent race conditions
global.__RSVP_CACHE_TIMER__ = true as any;
// initial immediate update (fire-and-forget)
updateCache().catch((e) => console.error("[rsvp] initial update failed:", e));
// schedule periodic updates
const interval = setInterval(() => {
updateCache().catch((e) => console.error("[rsvp] scheduled update failed:", e));
}, CACHE_DURATION_MS);
global.__RSVP_CACHE_TIMER__ = interval;

Copilot uses AI. Check for mistakes.
if (typeof process !== "undefined" && process.on) {
process.on("SIGTERM", shutdownRSVPTimer);
process.on("SIGINT", shutdownRSVPTimer);
process.on("exit", shutdownRSVPTimer);
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

The 'exit' event does not support asynchronous operations, and handlers should be synchronous. While shutdownRSVPTimer() is synchronous, registering cleanup on 'exit' after 'SIGTERM' and 'SIGINT' is redundant because those signals already trigger the exit event. More importantly, in serverless environments (like Vercel), process event listeners may not behave as expected. Consider removing this line or documenting that it's specifically for local development.

Suggested change
process.on("exit", shutdownRSVPTimer);
// Removed 'exit' event handler registration; see CodeQL warning.

Copilot uses AI. Check for mistakes.
href?: string;
disable?: boolean;
children: React.ReactNode;
children: ReactNode;
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent React type import usage. Line 4 uses React.ButtonHTMLAttributes (namespace import), but line 9 now uses ReactNode (named import). For consistency, either use React.ReactNode without the import on line 2, or change line 4 to use a named import like ButtonHTMLAttributes from 'react'. The current mixed approach is valid but inconsistent.

Copilot uses AI. Check for mistakes.
@boykisserchan boykisserchan merged commit b8ed3d5 into main Nov 6, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants