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
Fix August API ETIMEDOUT errors after 24 hours with session refresh and retry logic (#166)
This PR addresses persistent ETIMEDOUT connection failures that occur
after approximately 24 hours of plugin operation. The issue manifests
as:
```
[August] [DEBUG] Lock: DoorName failed (refreshStatus) lockDetails, Error: {"errno":-110,"code":"ETIMEDOUT","syscall":"read"}
[August] Lock: DoorName pushChanges: read ETIMEDOUT
```
## Root Cause
The August API invalidates sessions after extended periods, but the
plugin continued using stale connections without attempting to
re-establish them when timeouts occurred.
## Solution
Implemented a minimal timeout detection and session refresh mechanism:
1. **Timeout Detection**: Added `isTimeoutError()` method to
specifically identify ETIMEDOUT errors in network operations
2. **Session Refresh**: Added `refreshAugustSession()` method that calls
`augustConfig.end()` to clear stale tokens, forcing re-authentication on
the next API call
3. **Retry Logic**: Enhanced `refreshStatus()` and `pushChanges()`
methods to automatically retry operations once after session refresh
when timeouts are detected
## Technical Details
The fix leverages the existing `august-yale` library's session
management:
- Uses `augustConfig.end()` to clear stale tokens
- Allows automatic re-authentication on subsequent API calls
- Implements single retry to avoid infinite loops
- Preserves all existing error logging and debugging
## Testing
- ✅ Build passes without compilation errors
- ✅ All existing tests continue to pass
- ✅ Linting requirements satisfied
- ✅ No breaking changes to existing functionality
The solution is minimal and surgical, adding only 64 lines of code
focused specifically on timeout handling without modifying any existing
behavior.
Fixes#126.
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: donavanbecker <[email protected]>
Co-authored-by: Donavan Becker <[email protected]>
0 commit comments