feat: add race condition test for calendar-cache-serve booking flow#22170
feat: add race condition test for calendar-cache-serve booking flow#22170
Conversation
- Reproduces double-booking when two guests book same timeslot 1-2s apart - Enables both calendar-cache and calendar-cache-serve feature flags - Uses parallel browser contexts to simulate concurrent booking attempts - Verifies both bookings succeed and create double-booking scenario Co-Authored-By: zomars@cal.com <zomars@me.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
|
✅ No security or compliance issues detected. Reviewed everything up to e92a959. Security Overview
Detected Code Changes
Reply to this PR with |
E2E results are ready! |
- Change page.waitForTimeout(1500) to use correct page context - Fix timeslot selection to ensure both contexts book same slot - Remove incorrect host assertion and add logging to demonstrate race condition - Test now successfully reproduces double-booking bug locally - Fixes 'end of central directory record signature not found' error Co-Authored-By: zomars@cal.com <zomars@me.com>
There was a problem hiding this comment.
cubic found 2 issues across 1 file. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
|
|
||
| const teamMemberships = await prisma.membership.findMany({ | ||
| where: { teamId: team.id }, | ||
| include: { user: true }, |
There was a problem hiding this comment.
Using include with Prisma returns all columns of the related user table, which violates the project guideline to avoid include and only fetch required fields via select, leading to unnecessary data exposure and performance overhead.
Graphite Automations"Add foundation team as reviewer" took an action on this PR • (07/08/25)1 reviewer was added to this PR based on Keith Williams's automation. |
…alcom#22170) * feat: add race condition test for calendar-cache-serve booking flow - Reproduces double-booking when two guests book same timeslot 1-2s apart - Enables both calendar-cache and calendar-cache-serve feature flags - Uses parallel browser contexts to simulate concurrent booking attempts - Verifies both bookings succeed and create double-booking scenario Co-Authored-By: zomars@cal.com <zomars@me.com> * fix: correct page reference in race condition test timeout - Change page.waitForTimeout(1500) to use correct page context - Fix timeslot selection to ensure both contexts book same slot - Remove incorrect host assertion and add logging to demonstrate race condition - Test now successfully reproduces double-booking bug locally - Fixes 'end of central directory record signature not found' error Co-Authored-By: zomars@cal.com <zomars@me.com> * Update booking-race-condition.e2e.ts * Update booking-race-condition.e2e.ts * Update booking-race-condition.e2e.ts * Update booking-race-condition.e2e.ts * Create scratchpad.md * Update booking-race-condition.e2e.ts * Delete scratchpad.md * Update booking-race-condition.e2e.ts * Update booking-race-condition.e2e.ts --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add Playwright test to reproduce booking race condition with calendar cache
refs #22065
Summary
This PR adds a Playwright end-to-end test that ensures we prevent a race condition in Cal.com's booking flow for team events with round-robin host assignment. The test demonstrates how two guests could book the same timeslot within 1-2 seconds when the
calendar-cache-servefeature flag is enabled, causing a double-booking issue due to stale calendar cache data.Key Implementation:
SchedulingType.ROUND_ROBINschedulingcalendar-cacheandcalendar-cache-servefeature flags viaprisma.teamFeatures.createMany()Test Results:
The test successfully reproduces the bug locally, consistently showing output like:
Review & Testing Checklist for Human
TZ=UTC PLAYWRIGHT_HEADLESS=1 yarn e2e apps/web/playwright/booking-race-condition.e2e.tsand confirm it consistently reproduces the double-booking scenario with different hosts assigned to the same timeslotab-tests-redirect.e2e.tsandapp-store.e2e.tswhile this test is not in that shard)calendar-cacheandcalendar-cache-serve) and that this matches the production scenario where the race condition occursDiagram
%%{ init : { "theme" : "default" }}%% graph TB Test["apps/web/playwright/booking-race-condition.e2e.ts"]:::major-edit Fixtures["apps/web/playwright/lib/fixtures.ts"]:::context TestUtils["apps/web/playwright/lib/testUtils.ts"]:::context Test --> Fixtures Test --> TestUtils Test --> PrismaFeatures["prisma.teamFeatures.createMany()"]:::context Test --> BookingAPI["/api/book/event"]:::context Test --> CalendarCache["packages/features/calendar-cache/"]:::context Test --> Context1["Browser Context 1 (Guest A)"]:::context Test --> Context2["Browser Context 2 (Guest B)"]:::context Context1 --> BookingFlow1["Booking Flow"]:::context Context2 --> BookingFlow2["Booking Flow"]:::context BookingFlow1 --> Database["Database Verification"]:::context BookingFlow2 --> Database subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Link to Devin run: https://app.devin.ai/sessions/02516b4cc3374102a0d73a11d665ab62
Requested by: zomars (@zomars)