perf: add jittered backoff and parameter building utilities#89
perf: add jittered backoff and parameter building utilities#89samadrehman wants to merge 2 commits into
Conversation
|
@samadrehman is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey there and thank you for opening this pull request! We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Introduces shared helpers for building request params/bodies and improves API retry behavior by adding jittered exponential backoff, then refactors several tools to use the new utilities.
Changes:
- Added
buildParams/buildBodyutilities to remove repetitiveundefinedchecks when constructing query params and request bodies - Added jitter to exponential backoff in
calApiretries to reduce thundering-herd effects - Refactored schedules, bookings, and availability tools to use the new builders
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/mcp-server/src/utils/params-builder.ts | Adds reusable helpers to construct query params and request bodies while omitting undefined values |
| apps/mcp-server/src/utils/api-client.ts | Introduces jittered exponential backoff for retry sleep timing |
| apps/mcp-server/src/tools/schedules.ts | Replaces manual body construction with buildBody |
| apps/mcp-server/src/tools/bookings.ts | Replaces manual query/body construction with buildParams / buildBody |
| apps/mcp-server/src/tools/availability.ts | Uses buildParams to simplify query param building (with a subtle behavior change) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Optimized Cal.com Companion MCP server by addressing distributed retry patterns and code duplication:
Performance Improvements:
Added jittered exponential backoff to API retry logic, preventing thundering herd problem in distributed systems
Reduces collision risk when multiple clients retry simultaneously using formula: delay * 2^attempt * (1 + random(0-1))
Code Quality:
Created reusable buildParams() and buildBody() utilities to eliminate verbose if-check patterns
Refactored 7 critical functions across bookings, schedules, and availability tools
Reduced parameter-building boilerplate by ~80 lines of code
Testing & Validation:
All 18 test files passing (203 tests)
Zero compile errors
Full backward compatibility maintained
Files Modified:
api-client.ts - Jittered backoff implementation
params-builder.ts - NEW utility module
bookings.ts - Refactored 4 functions
schedules.ts - Refactored 2 functions
availability.ts - Refactored 1 functio
Summary by cubic
Add jittered exponential backoff to the MCP server API client to smooth retries and prevent thundering herd. Add small utilities to build params/bodies and refactor bookings, schedules, and availability to remove boilerplate with no behavior changes.
New Features
Refactors
buildParamsandbuildBodyutils and applied them across bookings, schedules, and availability.Written for commit 7660f6c. Summary will update on new commits. Review in cubic