Improved robustness for Roborock IoT REST calls — Summary
Overview
Improved resilience and error handling for Roborock IoT REST interactions, tightened test typings, and ensured lint/tests pass.
Key fixes
- Resilience: Implemented an
axiosinstance with timeout, keep-alive agent, and retry/backoff viaaxios-retryto handle transient network errors (includingECONNRESET,ETIMEDOUT). - Error handling: Wrapped REST calls and scheduled async handlers with
try/catchso transient failures returnundefinedinstead of causing unhandled rejections. - Typing: Removed
anyusages in tests and replaced them with explicit mock interfaces andunknown-based casts. - Lint/tests: Fixed ESLint issues and updated tests; full suite and lint now pass locally.
Files changed (notable)
roborockIoTApi.ts— axios config, retry logic, try/catch on API methods.module.ts— wrapped periodic/initialrequestHomeData()calls withtry/catch.package.json— addedaxios-retrydependency.roborockIoTApi.test.ts— new/updated unit tests for retry/exception behavior.roborockService4.test.ts— removedany, added mock interfaces, adjusted expectations.eslint.config.js— minor config updates to avoid parser issues.
Behavior notes / migration
- API methods may now return
undefinedon transient failure where previously they could throw — callers should handleundefined(tests were updated). - Retries/backoff are enabled (3 attempts, exponential backoff). Monitor behavior in production and tune counts/delays if needed.
Test & lint status
- All tests pass locally: 30 suites, 249 tests.
- ESLint passes.