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 hub update status monitoring: handle empty responses with retry logic
- Added empty response detection before JSON parsing to prevent parse errors
- Implemented retry logic with exponential backoff (2s, 4s, 8s) in polling loop
- Added better error messages for empty/blank responses
- Added tests for empty response handling and rapid polling
- Version 3.3 validated against live Hubitat system
This fixes the 'Cannot read Json element because of unexpected end of the input'
errors that occur when hubs return empty responses during updates or restarts.
During hub update monitoring with polling, the system would fail with "Cannot read Json element because of unexpected end of the input" errors when the hub returned empty responses. This typically happens when:
7
+
- The hub is busy processing an update
8
+
- The hub is temporarily restarting
9
+
- Network issues cause incomplete responses
10
+
11
+
### Solution
12
+
Added robust error handling and retry logic:
13
+
14
+
1.**Empty Response Detection**: Check for blank responses before attempting JSON parsing
15
+
2.**Retry Logic with Exponential Backoff**: Automatically retry failed version checks up to 3 times with increasing delays (2s, 4s, 8s)
16
+
3.**Better Error Messages**: Clear error messages indicating when empty responses are received
17
+
18
+
### Changes Made
19
+
- Added empty response check in `HubOperations.getHubVersions()`
20
+
- Implemented retry logic with exponential backoff in `updateHubsWithPolling()` polling loop
21
+
- Added test for empty response handling
22
+
- Added test for multiple rapid version checks
23
+
24
+
### Error Handling Flow
25
+
```
26
+
Attempt 1: Empty response → Wait 2s
27
+
Attempt 2: Empty response → Wait 4s
28
+
Attempt 3: Empty response → Wait 8s
29
+
Attempt 4: Still failing → Mark as failed
30
+
```
31
+
32
+
### Testing
33
+
- All unit tests pass (107 tests)
34
+
- All integration tests pass (7 real tests against live Hubitat system)
35
+
- New test validates empty response handling
36
+
- Tested rapid polling (5 consecutive calls) against live system
0 commit comments