You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
FixesJhaSourav07#2453
This PR resolves three reliability and correctness issues across the
application:
### 1. Timezone Shift Bug in GitHub Wrapped Busiest Month
The busiest month display was generated using:
```ts
new Date(wrappedData.busiestMonth + "-01")
```
Because date-only strings are interpreted as UTC, users in negative
timezone offsets could see the month shifted backward (e.g. December
displayed as November).
#### Fix
Replaced UTC-sensitive parsing with timezone-safe date construction to
ensure consistent month rendering across all user timezones.
---
### 2. Unbounded Memory Growth in Singleton Tracking Services
The following singleton services stored data in unbounded in-memory
Maps:
* refresh-rate-limiter.ts
* refresh-policy.ts
* track-user-protection.ts
Because entries were never removed, memory usage could continuously
increase as new users, IPs, or identifiers were encountered.
#### Fix
Migrated tracking storage to TTL-based caching so expired entries are
automatically cleaned up after their cooldown periods.
Benefits:
* Prevents stale entry accumulation
* Reduces long-term memory usage
* Avoids potential OOM issues in long-running deployments
---
### 3. Incorrect Rate Limit Reset Timestamp
The rate limiter returned:
```ts
reset: now + windowMs
```
for every request.
This caused the `X-RateLimit-Reset` value to continuously move forward
even though the actual cache expiration remained fixed.
#### Fix
Added a persistent `resetAt` timestamp to tracker records and returned
that value instead of recalculating it on every request.
Benefits:
* Accurate rate-limit reset headers
* Correct retry timing for API consumers
* Consistent server/client behavior
---
### Testing
Verified:
* Busiest month displays correctly across multiple timezone offsets.
* Expired tracking entries are automatically removed.
* Memory usage remains stable during repeated requests.
* Rate-limit reset headers remain fixed throughout the active window.
* Existing rate limiting behavior remains unchanged.
## Pillar
* [ ] 🎨 Pillar 1 — New Theme Design
* [ ] 📐 Pillar 2 — Geometric SVG Improvement
* [x] 🕐 Pillar 3 — Timezone Logic Optimization
* [x] 🛠️ Other (Bug fix, refactoring, docs)
## Checklist before requesting a review:
* [x] I have read the `CONTRIBUTING.md` file.
* [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
* [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
* [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
* [ ] I have updated `README.md` if I added a new theme or URL
parameter. (Not applicable)
* [x] I have started the repo.
* [x] I have made sure that I have only one commit to merge in this PR.
* [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
* [ ] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.
0 commit comments