Commit 5918b87
fix: ensure connections field is always array instead of null
Fixed critical bug where connection info was not being sent to the
server properly, causing connections to never display on the website.
Root Cause:
- When no connection files existed for a worker, connections was nil
- nil slice marshals to null in JSON
- Server checks: if (connectionChanged && workerStatus.connections)
- null is falsy in JavaScript, so server skipped processing
- Result: connections never synced to database
The Fix:
1. Always initialize connections as empty slice: make([]api.ConnectionInfo, 0)
2. Empty slice marshals to [] in JSON instead of null
3. [] is truthy in JavaScript, so server processes the connections
4. Server correctly handles empty arrays:
- Deletes old connections if worker reports []
- Adds new connections if worker reports [...]
- No-op if DB has [] and worker reports []
Changes Made:
- collectWorkerStatusFromHypervisor: Initialize connections as empty slice
- collectWorkerStatusFromConfig: Initialize connections as empty slice
- Both paths now send connections: [] instead of connections: null
This ensures:
- Connections are always synced to database when connectionChanged=true
- Empty connection arrays properly clear old connections from DB
- New connections are properly added to DB
- Connection display works correctly on frontend
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 79a42de commit 5918b87
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1171 | 1171 | | |
1172 | 1172 | | |
1173 | 1173 | | |
1174 | | - | |
| 1174 | + | |
| 1175 | + | |
1175 | 1176 | | |
1176 | 1177 | | |
1177 | 1178 | | |
| |||
1226 | 1227 | | |
1227 | 1228 | | |
1228 | 1229 | | |
1229 | | - | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1230 | 1236 | | |
1231 | 1237 | | |
1232 | 1238 | | |
| |||
0 commit comments