📌 Description
HealthCheckManager in src/config/health.ts caches the last report and checkAll() runs every checker in parallel via Promise.all(). Two gaps: (1) getLastReport() can return a stale report between background intervals, so /health/ready lags real degradation; (2) if a single checker hangs despite its own timeout, Promise.all blocks the whole endpoint. Add an optional forceRefresh and wrap each checker in a Promise.race timeout.
💡 Why it matters: A stale or hung health report can keep an unhealthy instance in rotation.
🧩 Requirements and context
- Add an optional
forceRefresh parameter to recompute checks on demand for readiness.
- Wrap each checker in
Promise.race([check, timeout]) so one hang cannot block the report.
- Mark a timed-out checker as degraded/unhealthy with a clear reason.
- Keep the background interval behaviour for liveness.
- Add tests for stale-vs-fresh and a hung checker.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b health-force-refresh-timeout
2. Implement changes
- Write/modify the relevant source:
src/config/health.ts, src/routes/health.ts
- Write comprehensive tests:
tests/health.test.ts, tests/health-ready.test.ts
- Add documentation: inline TSDoc + README health section
- Include TSDoc doc comments on
checkAll/getLastReport
- Validate security assumptions: forceRefresh cannot be abused for DoS
3. Test and commit
- Cover edge cases: stale report, forced refresh, hung checker timeout
- Include test output and security notes in the PR description.
Example commit message
feat(health): add forceRefresh and per-checker timeout race to HealthCheckManager
✅ Acceptance criteria
🔒 Security notes
Gate or rate-limit forceRefresh so an unauthenticated client cannot trigger expensive checks repeatedly (DoS vector).
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
HealthCheckManagerinsrc/config/health.tscaches the last report andcheckAll()runs every checker in parallel viaPromise.all(). Two gaps: (1)getLastReport()can return a stale report between background intervals, so/health/readylags real degradation; (2) if a single checker hangs despite its own timeout,Promise.allblocks the whole endpoint. Add an optionalforceRefreshand wrap each checker in aPromise.racetimeout.🧩 Requirements and context
forceRefreshparameter to recompute checks on demand for readiness.Promise.race([check, timeout])so one hang cannot block the report.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
src/config/health.ts,src/routes/health.tstests/health.test.ts,tests/health-ready.test.tscheckAll/getLastReport3. Test and commit
npm testExample commit message
✅ Acceptance criteria
forceRefreshrecomputes checks on demandPromise.racetimeout🔒 Security notes
Gate or rate-limit
forceRefreshso an unauthenticated client cannot trigger expensive checks repeatedly (DoS vector).📋 Guidelines