unifi-protect 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/README.md +4 -4
  2. package/dist/client/client.d.ts +38 -9
  3. package/dist/client/client.d.ts.map +1 -1
  4. package/dist/client/client.js +78 -25
  5. package/dist/client/client.js.map +1 -1
  6. package/dist/client/connection.d.ts +41 -10
  7. package/dist/client/connection.d.ts.map +1 -1
  8. package/dist/client/connection.js +245 -65
  9. package/dist/client/connection.js.map +1 -1
  10. package/dist/client/livestream-pool.d.ts +43 -24
  11. package/dist/client/livestream-pool.d.ts.map +1 -1
  12. package/dist/client/livestream-pool.js +195 -115
  13. package/dist/client/livestream-pool.js.map +1 -1
  14. package/dist/clock.d.ts +131 -35
  15. package/dist/clock.d.ts.map +1 -1
  16. package/dist/clock.js +162 -9
  17. package/dist/clock.js.map +1 -1
  18. package/dist/devices/camera.d.ts +3 -3
  19. package/dist/devices/camera.d.ts.map +1 -1
  20. package/dist/devices/camera.js +4 -5
  21. package/dist/devices/camera.js.map +1 -1
  22. package/dist/devices/chime.d.ts +2 -2
  23. package/dist/devices/chime.d.ts.map +1 -1
  24. package/dist/devices/chime.js +3 -4
  25. package/dist/devices/chime.js.map +1 -1
  26. package/dist/devices/context.d.ts +3 -2
  27. package/dist/devices/context.d.ts.map +1 -1
  28. package/dist/devices/endpoints.d.ts +1 -1
  29. package/dist/devices/endpoints.js +1 -1
  30. package/dist/devices/fob.d.ts.map +1 -1
  31. package/dist/devices/fob.js +1 -2
  32. package/dist/devices/fob.js.map +1 -1
  33. package/dist/devices/light.d.ts.map +1 -1
  34. package/dist/devices/light.js +1 -2
  35. package/dist/devices/light.js.map +1 -1
  36. package/dist/devices/registry.d.ts.map +1 -1
  37. package/dist/devices/registry.js +4 -3
  38. package/dist/devices/registry.js.map +1 -1
  39. package/dist/devices/relay.d.ts.map +1 -1
  40. package/dist/devices/relay.js +1 -2
  41. package/dist/devices/relay.js.map +1 -1
  42. package/dist/devices/sensor.d.ts +2 -2
  43. package/dist/devices/sensor.d.ts.map +1 -1
  44. package/dist/devices/sensor.js +3 -4
  45. package/dist/devices/sensor.js.map +1 -1
  46. package/dist/devices/viewer.d.ts +2 -2
  47. package/dist/devices/viewer.d.ts.map +1 -1
  48. package/dist/devices/viewer.js +3 -4
  49. package/dist/devices/viewer.js.map +1 -1
  50. package/dist/diagnostics.d.ts +45 -30
  51. package/dist/diagnostics.d.ts.map +1 -1
  52. package/dist/diagnostics.js +14 -13
  53. package/dist/diagnostics.js.map +1 -1
  54. package/dist/errors.d.ts +191 -54
  55. package/dist/errors.d.ts.map +1 -1
  56. package/dist/errors.js +232 -45
  57. package/dist/errors.js.map +1 -1
  58. package/dist/event-bus.d.ts +15 -4
  59. package/dist/event-bus.d.ts.map +1 -1
  60. package/dist/event-bus.js +32 -9
  61. package/dist/event-bus.js.map +1 -1
  62. package/dist/index.d.ts +10 -5
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +22 -8
  65. package/dist/index.js.map +1 -1
  66. package/dist/logging.d.ts +6 -0
  67. package/dist/logging.d.ts.map +1 -1
  68. package/dist/logging.js.map +1 -1
  69. package/dist/protocol/address.d.ts +28 -0
  70. package/dist/protocol/address.d.ts.map +1 -0
  71. package/dist/protocol/address.js +52 -0
  72. package/dist/protocol/address.js.map +1 -0
  73. package/dist/protocol/events.d.ts +16 -15
  74. package/dist/protocol/events.d.ts.map +1 -1
  75. package/dist/protocol/events.js +45 -33
  76. package/dist/protocol/events.js.map +1 -1
  77. package/dist/protocol/init-segment.d.ts +108 -0
  78. package/dist/protocol/init-segment.d.ts.map +1 -0
  79. package/dist/protocol/init-segment.js +441 -0
  80. package/dist/protocol/init-segment.js.map +1 -0
  81. package/dist/protocol/plain-object.d.ts +24 -0
  82. package/dist/protocol/plain-object.d.ts.map +1 -0
  83. package/dist/protocol/plain-object.js +34 -0
  84. package/dist/protocol/plain-object.js.map +1 -0
  85. package/dist/protocol/reducer.d.ts +17 -11
  86. package/dist/protocol/reducer.d.ts.map +1 -1
  87. package/dist/protocol/reducer.js +59 -21
  88. package/dist/protocol/reducer.js.map +1 -1
  89. package/dist/schema-manifest.json +1 -1
  90. package/dist/settings.d.ts +178 -0
  91. package/dist/settings.d.ts.map +1 -1
  92. package/dist/settings.js +178 -87
  93. package/dist/settings.js.map +1 -1
  94. package/dist/state/selectors.d.ts +19 -22
  95. package/dist/state/selectors.d.ts.map +1 -1
  96. package/dist/state/selectors.js +18 -41
  97. package/dist/state/selectors.js.map +1 -1
  98. package/dist/state/store.d.ts +9 -1
  99. package/dist/state/store.d.ts.map +1 -1
  100. package/dist/state/store.js +37 -9
  101. package/dist/state/store.js.map +1 -1
  102. package/dist/transport/auth.d.ts +21 -9
  103. package/dist/transport/auth.d.ts.map +1 -1
  104. package/dist/transport/auth.js +107 -47
  105. package/dist/transport/auth.js.map +1 -1
  106. package/dist/transport/connection-fault.d.ts +24 -0
  107. package/dist/transport/connection-fault.d.ts.map +1 -0
  108. package/dist/transport/connection-fault.js +42 -0
  109. package/dist/transport/connection-fault.js.map +1 -0
  110. package/dist/transport/connector.d.ts +93 -0
  111. package/dist/transport/connector.d.ts.map +1 -0
  112. package/dist/transport/connector.js +111 -0
  113. package/dist/transport/connector.js.map +1 -0
  114. package/dist/transport/events-stream.d.ts +30 -15
  115. package/dist/transport/events-stream.d.ts.map +1 -1
  116. package/dist/transport/events-stream.js +246 -116
  117. package/dist/transport/events-stream.js.map +1 -1
  118. package/dist/transport/failure.d.ts +50 -0
  119. package/dist/transport/failure.d.ts.map +1 -0
  120. package/dist/transport/failure.js +141 -0
  121. package/dist/transport/failure.js.map +1 -0
  122. package/dist/transport/http.d.ts +102 -23
  123. package/dist/transport/http.d.ts.map +1 -1
  124. package/dist/transport/http.js +408 -111
  125. package/dist/transport/http.js.map +1 -1
  126. package/dist/transport/livestream-session.d.ts +25 -23
  127. package/dist/transport/livestream-session.d.ts.map +1 -1
  128. package/dist/transport/livestream-session.js +176 -88
  129. package/dist/transport/livestream-session.js.map +1 -1
  130. package/dist/transport/talkback-session.d.ts +25 -15
  131. package/dist/transport/talkback-session.d.ts.map +1 -1
  132. package/dist/transport/talkback-session.js +203 -105
  133. package/dist/transport/talkback-session.js.map +1 -1
  134. package/dist/transport/url-host.d.ts +68 -0
  135. package/dist/transport/url-host.d.ts.map +1 -0
  136. package/dist/transport/url-host.js +112 -0
  137. package/dist/transport/url-host.js.map +1 -0
  138. package/dist/transport/ws-endpoint.d.ts +6 -5
  139. package/dist/transport/ws-endpoint.d.ts.map +1 -1
  140. package/dist/transport/ws-endpoint.js +13 -9
  141. package/dist/transport/ws-endpoint.js.map +1 -1
  142. package/dist/transport/ws.d.ts +112 -3
  143. package/dist/transport/ws.d.ts.map +1 -1
  144. package/dist/transport/ws.js +125 -1
  145. package/dist/transport/ws.js.map +1 -1
  146. package/dist/types/base.d.ts +15 -11
  147. package/dist/types/base.d.ts.map +1 -1
  148. package/dist/types/camera.d.ts +110 -48
  149. package/dist/types/camera.d.ts.map +1 -1
  150. package/dist/types/chime.d.ts +2 -2
  151. package/dist/types/chime.d.ts.map +1 -1
  152. package/dist/types/index.d.ts +1 -0
  153. package/dist/types/index.d.ts.map +1 -1
  154. package/dist/types/nvr.d.ts +276 -11
  155. package/dist/types/nvr.d.ts.map +1 -1
  156. package/dist/types/relay.d.ts +2 -3
  157. package/dist/types/relay.d.ts.map +1 -1
  158. package/dist/types/sensor.d.ts +35 -12
  159. package/dist/types/sensor.d.ts.map +1 -1
  160. package/dist/types/shapes.d.ts +54 -2
  161. package/dist/types/shapes.d.ts.map +1 -1
  162. package/dist/types/siren.d.ts +45 -0
  163. package/dist/types/siren.d.ts.map +1 -0
  164. package/dist/types/siren.js +2 -0
  165. package/dist/types/siren.js.map +1 -0
  166. package/dist/util/cli/client.d.ts +3 -3
  167. package/dist/util/cli/client.js +3 -3
  168. package/dist/util/cli/commands/camera.d.ts.map +1 -1
  169. package/dist/util/cli/commands/camera.js +7 -42
  170. package/dist/util/cli/commands/camera.js.map +1 -1
  171. package/dist/util/cli/commands/capture.d.ts +4 -4
  172. package/dist/util/cli/commands/capture.d.ts.map +1 -1
  173. package/dist/util/cli/commands/capture.js +59 -56
  174. package/dist/util/cli/commands/capture.js.map +1 -1
  175. package/dist/util/cli/commands/chime.d.ts.map +1 -1
  176. package/dist/util/cli/commands/chime.js +5 -37
  177. package/dist/util/cli/commands/chime.js.map +1 -1
  178. package/dist/util/cli/commands/diagnostics.d.ts.map +1 -1
  179. package/dist/util/cli/commands/diagnostics.js +8 -7
  180. package/dist/util/cli/commands/diagnostics.js.map +1 -1
  181. package/dist/util/cli/commands/doctor.d.ts.map +1 -1
  182. package/dist/util/cli/commands/doctor.js +36 -22
  183. package/dist/util/cli/commands/doctor.js.map +1 -1
  184. package/dist/util/cli/commands/info.d.ts.map +1 -1
  185. package/dist/util/cli/commands/info.js +31 -13
  186. package/dist/util/cli/commands/info.js.map +1 -1
  187. package/dist/util/cli/commands/reboot.d.ts.map +1 -1
  188. package/dist/util/cli/commands/reboot.js +6 -10
  189. package/dist/util/cli/commands/reboot.js.map +1 -1
  190. package/dist/util/cli/commands/relay-toggle.d.ts.map +1 -1
  191. package/dist/util/cli/commands/relay-toggle.js +12 -9
  192. package/dist/util/cli/commands/relay-toggle.js.map +1 -1
  193. package/dist/util/cli/commands/relay.d.ts.map +1 -1
  194. package/dist/util/cli/commands/relay.js +5 -37
  195. package/dist/util/cli/commands/relay.js.map +1 -1
  196. package/dist/util/cli/commands/update.d.ts.map +1 -1
  197. package/dist/util/cli/commands/update.js +5 -3
  198. package/dist/util/cli/commands/update.js.map +1 -1
  199. package/dist/util/cli/commands/watch-events.d.ts.map +1 -1
  200. package/dist/util/cli/commands/watch-events.js +5 -14
  201. package/dist/util/cli/commands/watch-events.js.map +1 -1
  202. package/dist/util/cli/commands/watch-livestream.d.ts.map +1 -1
  203. package/dist/util/cli/commands/watch-livestream.js +15 -10
  204. package/dist/util/cli/commands/watch-livestream.js.map +1 -1
  205. package/dist/util/cli/commands/watch-raw.d.ts.map +1 -1
  206. package/dist/util/cli/commands/watch-raw.js +11 -17
  207. package/dist/util/cli/commands/watch-raw.js.map +1 -1
  208. package/dist/util/cli/commands/watch-state.d.ts.map +1 -1
  209. package/dist/util/cli/commands/watch-state.js +23 -23
  210. package/dist/util/cli/commands/watch-state.js.map +1 -1
  211. package/dist/util/cli/commands/watch.d.ts.map +1 -1
  212. package/dist/util/cli/commands/watch.js +4 -35
  213. package/dist/util/cli/commands/watch.js.map +1 -1
  214. package/dist/util/cli/credentials.d.ts +7 -6
  215. package/dist/util/cli/credentials.d.ts.map +1 -1
  216. package/dist/util/cli/credentials.js +49 -21
  217. package/dist/util/cli/credentials.js.map +1 -1
  218. package/dist/util/cli/diagnostics-feed.d.ts +2 -1
  219. package/dist/util/cli/diagnostics-feed.d.ts.map +1 -1
  220. package/dist/util/cli/diagnostics-feed.js +12 -4
  221. package/dist/util/cli/diagnostics-feed.js.map +1 -1
  222. package/dist/util/cli/index.js +10 -6
  223. package/dist/util/cli/index.js.map +1 -1
  224. package/dist/util/cli/lookup.d.ts +11 -9
  225. package/dist/util/cli/lookup.d.ts.map +1 -1
  226. package/dist/util/cli/lookup.js +25 -15
  227. package/dist/util/cli/lookup.js.map +1 -1
  228. package/dist/util/cli/manifest.d.ts +95 -1
  229. package/dist/util/cli/manifest.d.ts.map +1 -1
  230. package/dist/util/cli/manifest.js +158 -29
  231. package/dist/util/cli/manifest.js.map +1 -1
  232. package/dist/util/cli/output/format.d.ts +20 -4
  233. package/dist/util/cli/output/format.d.ts.map +1 -1
  234. package/dist/util/cli/output/format.js +61 -13
  235. package/dist/util/cli/output/format.js.map +1 -1
  236. package/dist/util/cli/scrub.d.ts +24 -18
  237. package/dist/util/cli/scrub.d.ts.map +1 -1
  238. package/dist/util/cli/scrub.js +334 -70
  239. package/dist/util/cli/scrub.js.map +1 -1
  240. package/dist/util/cli/shared.d.ts +34 -1
  241. package/dist/util/cli/shared.d.ts.map +1 -1
  242. package/dist/util/cli/shared.js +132 -89
  243. package/dist/util/cli/shared.js.map +1 -1
  244. package/package.json +9 -9
  245. package/src/client/client.ts +104 -30
  246. package/src/client/connection.ts +323 -75
  247. package/src/client/livestream-pool.ts +239 -138
  248. package/src/clock.ts +285 -37
  249. package/src/devices/camera.ts +6 -6
  250. package/src/devices/chime.ts +3 -4
  251. package/src/devices/context.ts +3 -2
  252. package/src/devices/endpoints.ts +1 -1
  253. package/src/devices/fob.ts +1 -2
  254. package/src/devices/light.ts +1 -2
  255. package/src/devices/registry.ts +8 -5
  256. package/src/devices/relay.ts +1 -2
  257. package/src/devices/sensor.ts +3 -4
  258. package/src/devices/viewer.ts +3 -4
  259. package/src/diagnostics.ts +45 -30
  260. package/src/errors.ts +276 -54
  261. package/src/event-bus.ts +37 -9
  262. package/src/index.ts +46 -27
  263. package/src/logging.ts +6 -0
  264. package/src/protocol/address.ts +57 -0
  265. package/src/protocol/events.ts +48 -37
  266. package/src/protocol/init-segment.ts +760 -0
  267. package/src/protocol/plain-object.ts +39 -0
  268. package/src/protocol/reducer.ts +79 -27
  269. package/src/settings.ts +183 -87
  270. package/src/state/selectors.ts +35 -45
  271. package/src/state/store.ts +47 -13
  272. package/src/transport/auth.ts +112 -53
  273. package/src/transport/connection-fault.ts +90 -0
  274. package/src/transport/connector.ts +203 -0
  275. package/src/transport/events-stream.ts +293 -136
  276. package/src/transport/failure.ts +234 -0
  277. package/src/transport/http.ts +423 -120
  278. package/src/transport/livestream-session.ts +224 -112
  279. package/src/transport/talkback-session.ts +245 -122
  280. package/src/transport/url-host.ts +135 -0
  281. package/src/transport/ws-endpoint.ts +14 -9
  282. package/src/transport/ws.ts +208 -4
  283. package/src/types/base.ts +19 -11
  284. package/src/types/camera.ts +120 -50
  285. package/src/types/chime.ts +2 -2
  286. package/src/types/index.ts +1 -0
  287. package/src/types/nvr.ts +278 -12
  288. package/src/types/relay.ts +4 -2
  289. package/src/types/sensor.ts +45 -17
  290. package/src/types/shapes.ts +53 -2
  291. package/src/types/siren.ts +60 -0
  292. package/src/util/cli/client.ts +3 -3
  293. package/src/util/cli/commands/camera.ts +8 -50
  294. package/src/util/cli/commands/capture.ts +68 -66
  295. package/src/util/cli/commands/chime.ts +6 -45
  296. package/src/util/cli/commands/diagnostics.ts +8 -7
  297. package/src/util/cli/commands/doctor.ts +42 -24
  298. package/src/util/cli/commands/info.ts +35 -13
  299. package/src/util/cli/commands/reboot.ts +6 -13
  300. package/src/util/cli/commands/relay-toggle.ts +13 -9
  301. package/src/util/cli/commands/relay.ts +6 -45
  302. package/src/util/cli/commands/update.ts +7 -5
  303. package/src/util/cli/commands/watch-events.ts +6 -20
  304. package/src/util/cli/commands/watch-livestream.ts +16 -10
  305. package/src/util/cli/commands/watch-raw.ts +12 -22
  306. package/src/util/cli/commands/watch-state.ts +29 -32
  307. package/src/util/cli/commands/watch.ts +5 -43
  308. package/src/util/cli/credentials.ts +59 -24
  309. package/src/util/cli/diagnostics-feed.ts +6 -4
  310. package/src/util/cli/index.ts +10 -6
  311. package/src/util/cli/lookup.ts +28 -15
  312. package/src/util/cli/manifest.ts +241 -36
  313. package/src/util/cli/output/format.ts +83 -14
  314. package/src/util/cli/scrub.ts +395 -78
  315. package/src/util/cli/shared.ts +178 -127
@@ -3,13 +3,75 @@
3
3
  * connection.ts: ConnectionMonitor - the connection-state FSM, reboot detection, and auto-recovery coordinator that folds the transport throttle and the events-stream
4
4
  * stall into one observable health surface.
5
5
  */
6
- import { PROTECT_REBOOT_ANTICIPATION_WINDOW_MS, PROTECT_REBOOT_DETECTION_THRESHOLD, PROTECT_RECOVERY_BACKOFF_KNOWN_MS, PROTECT_RECOVERY_BACKOFF_UNKNOWN_MS, PROTECT_RECOVERY_STEADY_INTERVAL_MS } from "../settings.js";
7
- import { ProtectError, ProtectNetworkError } from "../errors.js";
6
+ import { PROTECT_REBOOT_ANTICIPATION_WINDOW_MS, PROTECT_REBOOT_DETECTION_THRESHOLD, PROTECT_RECOVERY_BACKOFF_KNOWN_MS, PROTECT_RECOVERY_BACKOFF_UNKNOWN_MS, PROTECT_RECOVERY_REFUSAL_SCHEDULE_MS, PROTECT_RECOVERY_STEADY_INTERVAL_MS } from "../settings.js";
7
+ import { ProtectError, ProtectNetworkError, ProtectRequestError, formatErrorChain, isControllerRefusal, isSignInRefusal, unwrapBootstrapError } from "../errors.js";
8
+ import { millisecondsSince, wallClock } from "../clock.js";
8
9
  import { EventBus } from "../event-bus.js";
9
10
  import { channels } from "../diagnostics.js";
11
+ import { classifyTransportError } from "../transport/failure.js";
12
+ import { connectionFaultLevel } from "../transport/connection-fault.js";
10
13
  import { noopLog } from "../logging.js";
11
14
  import { selectControllerUpSince } from "../state/selectors.js";
12
- import { wallClock } from "../clock.js";
15
+ const NETWORK_RECOVERY_SCHEDULES_MS = {
16
+ known: { backoff: PROTECT_RECOVERY_BACKOFF_KNOWN_MS, steady: PROTECT_RECOVERY_STEADY_INTERVAL_MS },
17
+ unknown: { backoff: PROTECT_RECOVERY_BACKOFF_UNKNOWN_MS, steady: PROTECT_RECOVERY_STEADY_INTERVAL_MS }
18
+ };
19
+ /* The wait a failed recovery attempt's answer asks for, in milliseconds, or null when it asks for none. A controller asks for time with a `Retry-After`, which the
20
+ * transport hands back at once among the headers of the `ProtectRequestError` it classifies the answer as: the liveness probe throws that error as itself, the
21
+ * re-bootstrap as the cause of a `ProtectBootstrapError`, and a relogin a 401 on one of them triggers throws its own answer's error as itself, unwrapped, so this
22
+ * reads the fault or the cause such a wrapper carries, by the one wrapper rule the readings of a refusal share. No other fault carries an answer's headers: a
23
+ * refused sign-in is classified without them, and a socket that fails, the live stream's or a relaunch's, has no answer to carry. A value of digits alone is
24
+ * delay-seconds, and any other value is read as an HTTP-date, a time of day, so its distance is taken from `now`, the clock's time of day at the read, rather than
25
+ * from the monotonic reading, whose origin is the platform's and not the epoch a date is written against. A value that reads as neither, or a distance of zero or
26
+ * less, asks for nothing. The wait is capped at the refusal schedule's steady interval, the slowest rung recovery walks, so a controller that asks for hours or
27
+ * names a date far out never parks recovery past it.
28
+ */
29
+ function recoveryHint(fault, options) {
30
+ const answer = unwrapBootstrapError(fault);
31
+ if (!(answer instanceof ProtectRequestError)) {
32
+ return null;
33
+ }
34
+ const value = answer.headers?.["retry-after"];
35
+ if (value === undefined) {
36
+ return null;
37
+ }
38
+ const wait = /^\d+$/.test(value) ? (Number(value) * 1000) : (Date.parse(value) - options.now);
39
+ // A value that reads as no date is NaN here, and NaN fails this comparison as a distance of zero or less does.
40
+ if (!(wait > 0)) {
41
+ return null;
42
+ }
43
+ return Math.min(wait, PROTECT_RECOVERY_REFUSAL_SCHEDULE_MS.steady);
44
+ }
45
+ /* The lost line for each class. A refused sign-in and a fault a person must fix log at error, because nothing changes until someone acts. A rate limit, the
46
+ * controller asking to be asked less often, and a fault that heals itself log at warning, which is the floor, because a lost connection always matters to a user
47
+ * even when recovery will clear it.
48
+ */
49
+ const LOSS_ANNOUNCEMENTS = {
50
+ mustFix: { level: "error",
51
+ sentence: "The UniFi Protect controller cannot be reached until its certificate or its address is fixed; the connection is lost and recovery is polling." },
52
+ rateLimited: { level: "warn",
53
+ sentence: "The UniFi Protect controller is rate limiting requests; the connection is lost and recovery is retrying on the slower refusal schedule." },
54
+ refused: { level: "error",
55
+ sentence: "The UniFi Protect controller is refusing the sign-in; the connection is lost and recovery is retrying on the slower refusal schedule." },
56
+ selfHealing: { level: "warn", sentence: "The UniFi Protect controller appears unreachable; the connection is lost and recovery is polling." }
57
+ };
58
+ /* The class a loss is announced as. The refusals are read first, above the level table, which reads a refused sign-in and a rate limit alike as a codeless failure
59
+ * like any other error type of this library's own: a refused sign-in, then any other refusal, which is a rate limit. Each is read by its published reading, so
60
+ * the class sees through the bootstrap wrapper exactly as the recovery schedule does, and a rate limit the re-bootstrap meets is announced as one. Every other
61
+ * reason asks the table with `open` false, and that is the rule's own answer rather than a choice: every reason a loss is concluded on is a one-shot request (the
62
+ * verify probe, the re-bootstrap) or a relaunch whose stream never opened, because a relaunch whose stream opens is a recovery. The table's error, a certificate
63
+ * nothing trusts or a host name that does not resolve, is a fault a person must fix, and every other answer, quiet among them, is a fault that heals itself, which
64
+ * is what holds the lost line at warning or above.
65
+ */
66
+ function lossClassOf(reason) {
67
+ if (isSignInRefusal(reason)) {
68
+ return "refused";
69
+ }
70
+ if (isControllerRefusal(reason)) {
71
+ return "rateLimited";
72
+ }
73
+ return (connectionFaultLevel(classifyTransportError(reason), { open: false }) === "error") ? "mustFix" : "selfHealing";
74
+ }
13
75
  /**
14
76
  * Owns the *replaceable* events stream behind a stable surface, so the monitor subscribes once and never re-attaches across relaunches. It is the structural sibling of
15
77
  * the livestream pool's managed session: it builds the inner stream through the single injected factory (the initial stream and every relaunch), bridges the inner
@@ -18,15 +80,18 @@ import { wallClock } from "../clock.js";
18
80
  *
19
81
  * Both bridges are attached synchronously at build time, before any await, preserving the race-free "subscribe before open" property the composition root relies on. On
20
82
  * `relaunch` the subscriptions are disposed *before* the old stream is torn down, so a dying socket's late frames never reach the monitor or the firehose. For fault
21
- * detection it listens only to `error`, never `closed`: the `EventStream` routes every unsolicited termination there - a stall, a socket error, and an unsolicited close
22
- * (the peer dropping a live socket, e.g. a controller reboot, which arrives as a `close` with no socket `error`). A self-initiated close (relaunch / dispose) stays
23
- * informational on `closed`, so the error rail alone is the failure signal and `closed` needs no handling.
83
+ * detection it listens only to `error`, never `closed`: the `EventStream` routes every unsolicited termination of an open stream there - a stall, a socket error, and
84
+ * an unsolicited close (the peer dropping a live socket, e.g. a controller reboot, which arrives as a `close` with no socket `error`). A self-initiated close (relaunch
85
+ * / dispose) stays informational on `closed`, and a failure before the open reaches whoever awaits `opened` alone - the composition root's connect, or `relaunch`'s
86
+ * caller, which marks the monitor lost with it - so the error rail alone is the failure signal of an open stream and `closed` needs no handling.
24
87
  */
25
88
  class ManagedEventStream {
26
89
  #factory;
27
90
  #onError;
28
91
  #packetSink;
29
92
  #rawPacketSink;
93
+ // Whether the owner has been disposed, which a relaunch reads once its teardown settles, so a disposal that landed during that teardown builds nothing after it.
94
+ #disposed = false;
30
95
  // The current inner stream and the bridges into it. The subscriptions are disposed and rebuilt on every relaunch; the stream reference is replaced in lockstep.
31
96
  #stream;
32
97
  #subscriptions = [];
@@ -43,12 +108,17 @@ class ManagedEventStream {
43
108
  }
44
109
  /**
45
110
  * Tear the current stream down and bring up a fresh one seeded with the latest `lastUpdateId` (so the controller replays the gap), then await its open. The bridges
46
- * re-attach to the new stream inside `#build`, so the monitor's wiring is untouched.
111
+ * re-attach to the new stream inside `#build`, so the monitor's wiring is untouched. A disposal that lands during the teardown has ended the owner, so the
112
+ * relaunch then resolves having built nothing, since a stream built after disposal would have no owner left to close it; the monitor reads its own lifetime
113
+ * before it acts on the answer.
47
114
  *
48
115
  * @param lastUpdateId - The freshest update id from the recovery re-bootstrap.
49
116
  */
50
117
  async relaunch(lastUpdateId) {
51
118
  await this.#teardown();
119
+ if (this.#disposed) {
120
+ return;
121
+ }
52
122
  this.#stream = this.#build(lastUpdateId);
53
123
  await this.#stream.opened;
54
124
  }
@@ -56,6 +126,7 @@ class ManagedEventStream {
56
126
  * Dispose the owner: detach the bridges and tear the current stream down. Safe to call more than once, via the underlying stream's own repeat-safe close.
57
127
  */
58
128
  async [Symbol.asyncDispose]() {
129
+ this.#disposed = true;
59
130
  await this.#teardown();
60
131
  }
61
132
  // Build one inner stream and attach the stable bridges - packets to the sink, raw packets to the raw sink, errors to onError - synchronously, before the socket can
@@ -82,7 +153,7 @@ class ManagedEventStream {
82
153
  * @category Client
83
154
  */
84
155
  export class ConnectionMonitor {
85
- #bus = new EventBus();
156
+ #bus;
86
157
  #clock;
87
158
  // One AbortController for the monitor's lifetime. It ends the reboot-observation loop and any recovery-interval wait; disposal aborts it.
88
159
  #controller = new AbortController();
@@ -94,22 +165,30 @@ export class ConnectionMonitor {
94
165
  #transport;
95
166
  #verifyProbe;
96
167
  // The recovery sub-state and the bookkeeping the FSM needs. `state` is derived from #phase and the transport's live throttle verdict, never stored. #lastFault is the
97
- // most recent typed fault (the transition reason and the controllerLost payload). #reportedState caches the last emitted derived state purely to dedup stateChanged.
168
+ // most recent typed fault: it supplies the transition reason and the controllerLost payload, whether it is a refusal, a refused sign-in or a rate limit alike,
169
+ // chooses the recovery schedule, and a `Retry-After` its answer carries can lengthen the next wait.
170
+ // #announcedLoss is the class the episode's loss was last announced as, null until an episode reaches `lost`, so a loss is announced again only when its class
171
+ // changes, controllerRecovered fires only after a genuine loss, and isLost is its public reading. #episodeTrack is the backoff track of the episode in progress,
172
+ // chosen by its opening fault, and "unknown" outside one, since a connection with no outage in progress is not a known reboot: recovery opens its network schedule
173
+ // on it and isRebooting reads it, so the track and the fact are one value decided once.
174
+ // #reportedState caches the last emitted derived state purely to dedup stateChanged.
98
175
  // #recovering guards against re-entrant recovery. #recoveryWake holds the abort handle for the in-flight backoff wait, or is null when recovery is not currently
99
- // parked on a wait. #wasLost records that an episode reached `lost`, so controllerRecovered fires only after a genuine loss. #lastUpSince tracks the controller's
100
- // last-seen boot time for reboot detection. #rebootAnticipatedUntil is the self-expiring deadline (clock time) armed by expectReboot(); a fault before it enters the
101
- // known-reboot backoff track, a fault after it the unknown one.
176
+ // parked on a wait. #lastUpSince tracks the controller's last-seen boot time for reboot detection. #rebootAnticipatedAt is the clock's monotonic reading when
177
+ // expectReboot() armed the self-expiring anticipation, null when none is armed; the fault that opens the next episode inside the window that follows it takes the
178
+ // known-reboot backoff track, and one after it the unknown one.
179
+ #announcedLoss = null;
180
+ #episodeTrack = "unknown";
102
181
  #lastFault = null;
103
182
  #lastUpSince;
104
183
  #phase = "healthy";
105
- #rebootAnticipatedUntil = null;
184
+ #rebootAnticipatedAt = null;
106
185
  #recovering = false;
107
186
  #recoveryWake = null;
108
187
  #reportedState;
109
- #wasLost = false;
110
188
  constructor(options) {
111
189
  this.#clock = options.clock ?? wallClock;
112
190
  this.#log = options.log ?? noopLog;
191
+ this.#bus = new EventBus(this.#log);
113
192
  this.#reBootstrap = options.reBootstrap;
114
193
  this.#store = options.store;
115
194
  this.#transport = options.transport;
@@ -145,6 +224,36 @@ export class ConnectionMonitor {
145
224
  get isHealthy() {
146
225
  return this.#derive() === "healthy";
147
226
  }
227
+ /**
228
+ * Whether the current recovery episode has concluded the connection lost. It turns true at the episode's first loss, the edge into `lost` that fires
229
+ * `controllerLost`, holds through every failed attempt and every `reconnecting` that follows, and turns false at the edge recovery completes on, into `healthy` or
230
+ * into `throttled` when the transport's breaker is open, which is the edge `controllerRecovered` follows. A fault that recovers before any attempt fails never
231
+ * turns it on.
232
+ *
233
+ * It changes only on a `stateChanged` transition: it is set before the edge into `lost` emits and cleared before the edge recovery completes on emits, so a
234
+ * listener reads at each edge the value that edge stands for. It can read true together with {@link ConnectionMonitor.isRebooting}, since an anticipated reboot
235
+ * can be lost too. Disposal emits no edge, so a disposed monitor keeps the value it last held.
236
+ */
237
+ get isLost() {
238
+ return this.#announcedLoss !== null;
239
+ }
240
+ /**
241
+ * Whether the current recovery episode is an anticipated controller reboot. It turns true at the edge into `degraded` when the fault that opens the episode lands
242
+ * inside the window {@link ProtectClient.reboot} arms once the controller accepts the reboot, holds through every phase recovery walks, a refusal or a long outage
243
+ * among them, and turns false at the edge recovery completes on, into `healthy` or into `throttled` when the transport's breaker is open. A reboot armed while an
244
+ * episode is underway leaves that episode as it opened and colors the next one if that episode opens inside the window.
245
+ *
246
+ * It changes only on a `stateChanged` transition: it is set before the edge into `degraded` emits and cleared before the edge recovery completes on emits, so a
247
+ * listener reads at each edge the value that edge stands for. It can read true together with {@link ConnectionMonitor.isLost}, since a controller that is slow to
248
+ * return from its reboot is lost as well. Disposal emits no edge, so a disposed monitor keeps the value it last held.
249
+ *
250
+ * This describes the connection to the controller, unlike the `isRebooting` field of a device record, which is the controller's report on that device. Recovery
251
+ * never gives up, so a controller that never returns keeps this true for as long as the monitor lives: a consumer that quiets its own presentation on it brings its
252
+ * own time limit.
253
+ */
254
+ get isRebooting() {
255
+ return this.#episodeTrack === "known";
256
+ }
148
257
  /** Whether the transport's throttle breaker is open. Delegates verbatim to the transport - the single source of truth for reachability backoff. */
149
258
  get isThrottled() {
150
259
  return this.#transport.isThrottled;
@@ -219,15 +328,17 @@ export class ConnectionMonitor {
219
328
  await this.#verifyProbe(opts.signal);
220
329
  }
221
330
  /**
222
- * Arm the monitor to treat the next connection fault as a *known* controller reboot, so recovery enters the long, return-time-anticipating backoff track rather than
223
- * the prompt one. Called by {@link ProtectClient.reboot} after the controller accepts the reboot - the one moment a fault's cause is certain. Package-internal: it is
224
- * not a consumer recovery trigger, only a hint that colors the recovery episode the imminent fault will trigger on its own.
331
+ * Arm the monitor to treat the fault that opens the next recovery episode as a *known* controller reboot, so recovery enters the long, return-time-anticipating
332
+ * backoff track rather than the prompt one and {@link ConnectionMonitor.isRebooting} reads true until recovery. Called by {@link ProtectClient.reboot} after the
333
+ * controller accepts the reboot - the one moment a fault's cause is certain. Package-internal: it is not a consumer recovery trigger, only a hint that colors the
334
+ * recovery episode the imminent fault will trigger on its own.
225
335
  *
226
- * The anticipation is bounded: it self-expires {@link PROTECT_REBOOT_ANTICIPATION_WINDOW_MS} after now, and is consumed by the next fault. So a reboot whose fault
227
- * never arrives cannot mis-route a much-later unrelated fault into the known track, and a fault after the window correctly takes the unknown track.
336
+ * The anticipation is bounded: it self-expires {@link PROTECT_REBOOT_ANTICIPATION_WINDOW_MS} after this call, and is consumed by the fault that opens the next episode,
337
+ * while a fault inside an episode already underway neither consumes it nor changes that episode's track. So a reboot whose fault never arrives cannot mis-route a
338
+ * much-later unrelated fault into the known track, and a fault after the window correctly takes the unknown track.
228
339
  */
229
340
  expectReboot() {
230
- this.#rebootAnticipatedUntil = this.#clock.now() + PROTECT_REBOOT_ANTICIPATION_WINDOW_MS;
341
+ this.#rebootAnticipatedAt = this.#clock.monotonic();
231
342
  }
232
343
  /**
233
344
  * Dispose the monitor: end the reboot-observation loop and any recovery wait, detach the throttle subscriptions, and tear the events stream down. A no-op on repeat.
@@ -254,27 +365,35 @@ export class ConnectionMonitor {
254
365
  }
255
366
  const from = this.#reportedState;
256
367
  this.#reportedState = next;
257
- const transition = { from, to: next, ...((this.#lastFault !== null) && { reason: this.#lastFault.message }) };
368
+ const transition = { from, to: next, ...((this.#lastFault !== null) && { reason: formatErrorChain(this.#lastFault) }) };
258
369
  this.#bus.emit("stateChanged", transition);
259
370
  if (channels.connectionTransition.hasSubscribers) {
260
371
  channels.connectionTransition.publish(transition);
261
372
  }
262
373
  }
263
- // Move to a recovery phase and recompute. Used for the non-terminal phases; entering `lost` goes through #enterLost so the controllerLost announcement fires once.
374
+ // Move to a recovery phase and recompute. Used for the non-terminal phases; entering `lost` goes through #enterLost instead, which owns the lost line and the
375
+ // controllerLost announcement.
264
376
  #enterPhase(phase) {
265
377
  this.#phase = phase;
266
378
  this.#recompute();
267
379
  }
268
- // Conclude the controller is unreachable. Announces controllerLost once per lost episode (on the transition into lost, not on every failed poll), records the fault,
269
- // and marks the episode so a later return to healthy fires controllerRecovered.
380
+ /* Conclude the connection is lost, recording the fault and the class it is announced as, which also marks the episode so a later return to healthy fires
381
+ * controllerRecovered. One rule announces the loss, in the lost line and on controllerLost alike: the episode's first loss, and each turn of its class among a
382
+ * refused sign-in, a rate limit, a fault a person must fix and a fault that heals itself, never a failed attempt that leaves its class unchanged - including one
383
+ * that answered the probe and passed through reconnecting before it failed. The one derivation of the class chooses the line's sentence and its level, while the
384
+ * recovery schedule keeps its own refusal-or-not reading of the same fault, so a refused sign-in turning into a rate limit is announced again on the rung it
385
+ * stood on.
386
+ */
270
387
  #enterLost(reason) {
271
- const announce = this.#phase !== "lost";
388
+ const announced = lossClassOf(reason);
389
+ const announce = announced !== this.#announcedLoss;
272
390
  this.#lastFault = reason;
273
391
  this.#phase = "lost";
274
- this.#wasLost = true;
392
+ this.#announcedLoss = announced;
275
393
  this.#recompute();
276
394
  if (announce) {
277
- this.#log.warn("The UniFi Protect controller appears unreachable; the connection is lost and recovery is polling.", { reason: reason.message });
395
+ const { level, sentence } = LOSS_ANNOUNCEMENTS[announced];
396
+ this.#log[level](sentence, { reason: formatErrorChain(reason) });
278
397
  this.#bus.emit("controllerLost", reason);
279
398
  }
280
399
  }
@@ -283,30 +402,35 @@ export class ConnectionMonitor {
283
402
  this.#bus.emit(entered ? "throttleEntered" : "throttleExited");
284
403
  this.#recompute();
285
404
  }
286
- // The events channel reported an unsolicited fault (a watchdog stall or a socket error). Record it, mark the connection degraded if it was healthy, and kick the
287
- // guarded recovery sequence. A deliberate relaunch/close fires no error, so this runs only for genuine faults.
405
+ // The events channel reported an unsolicited fault (a watchdog stall or a socket error). Record it, and if the connection was healthy, open an episode: choose its
406
+ // backoff track, consuming the one-shot reboot anticipation, before marking the connection degraded, so isRebooting already reads the episode's track at that
407
+ // edge. Then kick the guarded recovery sequence. A deliberate relaunch/close fires no error, so this runs only for genuine faults.
288
408
  #onStreamFault(err) {
289
409
  this.#lastFault = err;
290
- this.#log.debug("The UniFi Protect realtime events channel faulted; beginning recovery.", { reason: err.message });
410
+ this.#log.debug("The UniFi Protect realtime events channel faulted; beginning recovery.", { reason: formatErrorChain(err) });
291
411
  if (this.#phase === "healthy") {
412
+ this.#episodeTrack = this.#consumeRecoveryTrack();
292
413
  this.#enterPhase("degraded");
293
414
  }
294
415
  void this.#recover();
295
416
  }
296
- // The guarded recovery sequence: one backoff curve, chosen by fault certainty, that walks out to the steady floor and polls there until the controller returns or the
297
- // monitor is disposed. The #backoffDelays generator yields the delay before each probe (the staged prefix, then the floor forever), so the single loop is "wait the
298
- // next delay, then attempt." The wait ends when its delay elapses and we probe on schedule, when a reachability wake aborts it (a detected reboot proves the controller
299
- // is back, so we probe now rather than sleeping out the rest of the backoff), or when disposal aborts it and we end. Recovery therefore polls a slow-to-return
300
- // controller for as long as the monitor lives - it never gives up after a handful of failures. The #recovering guard makes re-entrant faults no-ops, so the track is
301
- // chosen (and the one-shot reboot anticipation consumed) once per episode, inside the guard.
417
+ // The guarded recovery sequence: a network schedule, opened on the track fault certainty chooses, and a slower refusal schedule, picked per attempt by the cause of the
418
+ // most recent fault and each walked out to a steady floor that recovery then polls at until the controller returns or the monitor is disposed. The #recoveryDelays
419
+ // generator yields the delay before each probe (the chosen schedule's staged prefix, then its floor forever, any of them lengthened to the wait a hinted probe or
420
+ // bootstrap answer asks for, up to the refusal schedule's steady interval), so the single loop is "wait the next delay, then attempt." The wait ends when its delay
421
+ // elapses and we probe on schedule, when a reachability wake aborts it (a detected reboot proves the controller is back, so we probe now rather than sleeping out
422
+ // the rest of the backoff), or when disposal aborts it and we end. Recovery therefore polls a slow-to-return or refusing controller for as long as the monitor
423
+ // lives - it never gives up after a handful of failures. The #recovering guard makes re-entrant faults no-ops, and the track the loop opens on is the one the
424
+ // episode's opening fault chose in #onStreamFault, so it is chosen (and the one-shot reboot anticipation consumed) once per episode.
302
425
  async #recover() {
303
426
  if (this.#recovering) {
304
427
  return;
305
428
  }
306
429
  this.#recovering = true;
307
- const track = this.#consumeRecoveryTrack();
308
430
  try {
309
- for (const delay of this.#backoffDelays(track)) {
431
+ // #onStreamFault is the one caller, and the phase leaves healthy only through its degraded edge, which sets the episode's track first, so the loop opens on
432
+ // the track this episode's opening fault chose.
433
+ for (const delay of this.#recoveryDelays(this.#episodeTrack)) {
310
434
  // Park on the next scheduled delay, but make the wait interruptible by a reachability wake distinct from disposal. We compose the monitor's lifetime
311
435
  // signal with a per-iteration wake controller: disposal aborts the former, #wakeRecovery() the latter. AbortSignal.any handles a pre-aborted lifetime signal
312
436
  // cleanly, and Node holds the composite's dependents weakly, so the per-poll composites are GC-reclaimed - bounded and negligible at the steady cadence.
@@ -315,7 +439,7 @@ export class ConnectionMonitor {
315
439
  this.#recoveryWake = wake;
316
440
  try {
317
441
  // eslint-disable-next-line no-await-in-loop
318
- await this.#clock.wait(delay, { signal: AbortSignal.any([this.#controller.signal, wake.signal]) });
442
+ await this.#clock.delay(delay, { signal: AbortSignal.any([this.#controller.signal, wake.signal]) });
319
443
  }
320
444
  catch {
321
445
  // The wait aborted. A monitor-lifetime abort means disposal, so we end recovery. Otherwise a reachability wake (a detected reboot) fired, so we fall
@@ -334,9 +458,10 @@ export class ConnectionMonitor {
334
458
  }
335
459
  }
336
460
  catch {
337
- // A real backstop, not dead code. #attemptRecovery's own catch calls #enterLost, which emits controllerLost/stateChanged through the EventBus, and a synchronous
338
- // consumer listener that throws would propagate back here; swallowing it keeps the detached `void this.#recover()` from surfacing as an unhandled rejection. The
339
- // wait's own abort (wake or disposal) is handled inside the loop, so this does not fire on disposal.
461
+ // A real backstop, not dead code. #attemptRecovery's own catch calls #enterLost, which logs the lost line through the injected logger and emits through the
462
+ // EventBus, whose wrapper contains a listener's throw by logging it through that same logger. The injected logger is therefore what this still guards: one that
463
+ // throws would propagate back here, and swallowing it keeps the detached `void this.#recover()` from surfacing as an unhandled rejection. The wait's own abort
464
+ // (wake or disposal) is handled inside the loop, so this does not fire on disposal.
340
465
  }
341
466
  finally {
342
467
  this.#recovering = false;
@@ -346,52 +471,104 @@ export class ConnectionMonitor {
346
471
  #wakeRecovery() {
347
472
  this.#recoveryWake?.abort();
348
473
  }
349
- // The delays, in milliseconds, before each successive recovery probe: the chosen track's staged prefix, then the shared steady floor forever. A known reboot walks the
350
- // long, return-time-anticipating curve; an unknown fault the prompt one (its leading zero reproduces "probe at once on the fault"). The infinite steady tail is what
351
- // makes recovery poll indefinitely - the loop ends only on success or disposal, never by exhausting the schedule.
352
- *#backoffDelays(track) {
353
- yield* (track === "known") ? PROTECT_RECOVERY_BACKOFF_KNOWN_MS : PROTECT_RECOVERY_BACKOFF_UNKNOWN_MS;
474
+ /* The delays, in milliseconds, before each successive recovery probe, chosen per attempt from the most recent recorded fault: a refusal, a refused sign-in or a
475
+ * rate limit alike, walks the published refusal schedule, and anything else walks the network schedule, the episode's track and then the shared steady floor. A
476
+ * known reboot opens on the long, return-time-anticipating curve; an unknown fault on the prompt one (its leading zero reproduces "probe at once on the fault").
477
+ * The choice is made when the loop asks for its next wait, which is after the attempt before it recorded its own fault, so each wait answers the attempt just
478
+ * made, and the first wait, read before any attempt, is the network schedule's.
479
+ *
480
+ * A failed attempt whose answer carries a `Retry-After`, read off the probe's error, the cause of the bootstrap error, or the unwrapped failure of a relogin a 401
481
+ * on the re-bootstrap triggers, waits the longer of its scheduled delay and the hint, the hint capped at the refusal schedule's steady interval, so recovery waits
482
+ * as long as a hinted probe or bootstrap answer asks up to its slowest rung and never parks longer. The hint is read on the same pull as the schedule and from the
483
+ * same fault, so it lengthens the wait after the attempt it answered and no other, and it moves no rung: a controller that stops hinting finds the schedule where
484
+ * it would stand had it never hinted.
485
+ *
486
+ * A change of cause starts the other schedule at its first rung, because each ladder's delays are measured from when its cause began: a refusal that follows a
487
+ * stretch of unreachability backs off from its own first refusal. A refusal that clears into a network fault restarts the unknown track rather than the episode's,
488
+ * because a refusal is the controller answering - any reboot the known track anticipated is over - so the controller is probed at once. A refused sign-in that
489
+ * turns into a rate limit, or back, changes no schedule, so it keeps its rung. The infinite steady tail is what makes recovery poll indefinitely - the loop ends
490
+ * only on success or disposal, never by exhausting the schedule.
491
+ */
492
+ *#recoveryDelays(track) {
493
+ let network = NETWORK_RECOVERY_SCHEDULES_MS[track];
494
+ let schedule = null;
495
+ let rung = 0;
354
496
  for (;;) {
355
- yield PROTECT_RECOVERY_STEADY_INTERVAL_MS;
497
+ const refused = isControllerRefusal(this.#lastFault);
498
+ if (!refused && (schedule === PROTECT_RECOVERY_REFUSAL_SCHEDULE_MS)) {
499
+ network = NETWORK_RECOVERY_SCHEDULES_MS.unknown;
500
+ }
501
+ const chosen = refused ? PROTECT_RECOVERY_REFUSAL_SCHEDULE_MS : network;
502
+ if (chosen !== schedule) {
503
+ schedule = chosen;
504
+ rung = 0;
505
+ }
506
+ const scheduled = chosen.backoff[rung] ?? chosen.steady;
507
+ const hint = recoveryHint(this.#lastFault, { now: this.#clock.now() }) ?? 0;
508
+ if (hint > scheduled) {
509
+ this.#log.debug("The UniFi Protect controller asked for more time, so recovery waits longer than its schedule before the next attempt.", { hintMs: hint });
510
+ }
511
+ yield Math.max(scheduled, hint);
512
+ rung++;
356
513
  }
357
514
  }
358
- // Choose the backoff track for an episode and consume the one-shot reboot anticipation. A fault inside the anticipation window armed by expectReboot() is a known
359
- // reboot (the long track); anything else is unknown (the prompt track). We clear the anticipation unconditionally so it is strictly one-shot - an expired or absent
360
- // window simply yields the unknown track. (A reboot issued while an unknown episode is already recovering does not upgrade the in-flight track; the steady floor still
361
- // recovers it within an interval of the controller's return, and the window self-expires - an acceptable, rare degradation, not a correctness gap.)
515
+ // Choose the backoff track for an episode at its opening fault and consume the one-shot reboot anticipation. A fault inside the anticipation window armed by
516
+ // expectReboot() is a known reboot (the long track); anything else is unknown (the prompt track). We clear the anticipation unconditionally so it is strictly
517
+ // one-shot - an expired or absent window simply yields the unknown track. (A reboot issued while an unknown episode is already recovering does not upgrade the
518
+ // in-flight track or turn isRebooting on; the steady floor still recovers it within an interval of the controller's return, and the window self-expires - an
519
+ // acceptable, rare degradation, not a correctness gap.)
362
520
  #consumeRecoveryTrack() {
363
- const anticipated = (this.#rebootAnticipatedUntil !== null) && (this.#clock.now() < this.#rebootAnticipatedUntil);
364
- this.#rebootAnticipatedUntil = null;
521
+ const anticipated = (this.#rebootAnticipatedAt !== null) &&
522
+ (millisecondsSince(this.#rebootAnticipatedAt, { clock: this.#clock }) < PROTECT_REBOOT_ANTICIPATION_WINDOW_MS);
523
+ this.#rebootAnticipatedAt = null;
365
524
  return anticipated ? "known" : "unknown";
366
525
  }
367
526
  // One recovery attempt: the verify -> re-bootstrap -> relaunch sequence. The verify probe and the re-bootstrap fetch both carry `probe: true` (wired at the
368
527
  // composition root), so they dispatch through an open breaker at this loop's cadence rather than waiting out the breaker's cooldown - the unification that makes the
369
528
  // monitor the single owner of re-probe cadence during recovery. A successful probe closes the breaker as a side effect of its own booking; the monitor never touches
370
529
  // breaker internals. Success returns true (the caller stops); a failure at any step drops to `lost` and returns false so the caller retries. Announcing `lost` is
371
- // a no-op on repeat (controllerLost fires once per episode), so repeated failures while a sluggish controller returns do not spam.
530
+ // a no-op on repeat while the fault keeps its class (controllerLost fires on the episode's first loss and on each change of class), so repeated failures while a
531
+ // sluggish controller returns do not spam. Disposal can land while any step is pending, so once each step settles the monitor's own signal is read before
532
+ // anything else runs: a disposed monitor returns true (the caller stops) with no further edge, line or event, whether the step resolved or rejected.
372
533
  async #attemptRecovery() {
534
+ // Read through a call rather than as a property, because the compiler would otherwise carry the first reading across the awaits below as a constant.
535
+ const disposed = () => this.#controller.signal.aborted;
373
536
  try {
374
537
  await this.#verifyProbe(this.#controller.signal);
538
+ if (disposed()) {
539
+ return true;
540
+ }
375
541
  this.#enterPhase("reconnecting");
376
542
  this.#publishReconnecting();
377
543
  const lastUpdateId = await this.#reBootstrap(this.#controller.signal);
544
+ if (disposed()) {
545
+ return true;
546
+ }
378
547
  await this.#managed.relaunch(lastUpdateId);
548
+ if (disposed()) {
549
+ return true;
550
+ }
379
551
  this.#onRecovered();
380
552
  return true;
381
553
  }
382
554
  catch (error) {
555
+ if (disposed()) {
556
+ return true;
557
+ }
383
558
  this.#enterLost((error instanceof ProtectError) ? error :
384
559
  new ProtectNetworkError("Recovery of the UniFi Protect connection failed.", { cause: error }));
385
560
  return false;
386
561
  }
387
562
  }
388
- // Recovery completed. Clear the fault, return to healthy, and announce recovery only if the episode had reached `lost` (a transient stall that re-bootstrapped without
389
- // the controller ever going unreachable does not warrant a controllerRecovered). The non-lost path still logs a quieter stream-level confirmation in the `else` so a
390
- // transient relaunch that announced "Reconnecting..." still has a visible resolution.
563
+ // Recovery completed. Clear the fault and end the episode, its loss cleared and its track reset before the edge recovery completes on, so isLost and isRebooting read
564
+ // false on it, return to healthy, which reads as throttled while the breaker is open, and announce recovery only if the episode had reached `lost` (a transient stall
565
+ // that re-bootstrapped without the controller ever going unreachable does not warrant a controllerRecovered). The non-lost path still logs a quieter stream-level
566
+ // confirmation in the `else` so a transient relaunch that announced "Reconnecting..." still has a visible resolution.
391
567
  #onRecovered() {
392
- const recovered = this.#wasLost;
568
+ const recovered = this.#announcedLoss !== null;
569
+ this.#announcedLoss = null;
570
+ this.#episodeTrack = "unknown";
393
571
  this.#lastFault = null;
394
- this.#wasLost = false;
395
572
  this.#enterPhase("healthy");
396
573
  if (recovered) {
397
574
  this.#log.info("Recovered the connection to the UniFi Protect controller.");
@@ -408,7 +585,8 @@ export class ConnectionMonitor {
408
585
  #publishReconnecting() {
409
586
  this.#log.info("Reconnecting the UniFi Protect realtime events stream.");
410
587
  if (channels.eventsReconnecting.hasSubscribers) {
411
- channels.eventsReconnecting.publish({ reason: this.#lastFault?.message ?? "the events channel faulted" });
588
+ const reason = (this.#lastFault !== null) ? formatErrorChain(this.#lastFault) : "the events channel faulted";
589
+ channels.eventsReconnecting.publish({ reason });
412
590
  }
413
591
  }
414
592
  // Watch the controller's self-reported boot time. `upSince` is a noisy measurement of the boot instant (live validation observed millisecond-level jitter across
@@ -423,9 +601,9 @@ export class ConnectionMonitor {
423
601
  this.#lastUpSince = upSince;
424
602
  if ((previousUpSince !== null) && (upSince !== null) && (Math.abs(upSince - previousUpSince) >= PROTECT_REBOOT_DETECTION_THRESHOLD)) {
425
603
  this.#log.info("The UniFi Protect controller restarted.");
426
- // A detected reboot is proof the controller is reachable again - this detection rides a successful bootstrap fetch - so we wake any parked recovery wait to
427
- // relaunch the events stream now rather than sleeping out the backoff. We wake before the emit so a throwing or slow consumer listener on controllerRebooted
428
- // cannot skip the wake.
604
+ // A detected reboot is proof the controller is reachable again - this detection follows a successful bootstrap fetch - so we wake any parked recovery wait
605
+ // to relaunch the events stream now rather than sleeping out the backoff. We wake before the emit: the bus contains a throwing controllerRebooted listener by
606
+ // logging it, so what the order still guards against is the injected logger throwing from inside that emit, which must not skip the wake.
429
607
  this.#wakeRecovery();
430
608
  this.#bus.emit("controllerRebooted", { newUpSince: upSince, previousUpSince });
431
609
  if (channels.connectionRebootDetected.hasSubscribers) {
@@ -435,7 +613,9 @@ export class ConnectionMonitor {
435
613
  }
436
614
  }
437
615
  catch {
438
- // The observe iterator ends on abort when the monitor is disposed. Swallowed as the loop's end.
616
+ // The observe iterator ends on abort when the monitor is disposed, and that is the loop's end. A listener's throw never reaches here, since the bus contains it,
617
+ // so the one other thing this still guards is the injected logger throwing from the loop's own lines, which also ends the loop rather than surfacing as an
618
+ // unhandled rejection from the detached `void this.#watchReboots()`.
439
619
  }
440
620
  }
441
621
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/client/connection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0BH,OAAO,EAAE,qCAAqC,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,mCAAmC,EACxJ,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAqGxC;;;;;;;;;;;GAWG;AACH,MAAM,kBAAkB;IAEb,QAAQ,CAA8D;IACtE,QAAQ,CAA8B;IACtC,WAAW,CAA8B;IACzC,cAAc,CAA8B;IAErD,gKAAgK;IAChK,OAAO,CAAc;IACrB,cAAc,GAAiB,EAAE,CAAC;IAElC,YAAY,OAOX;QAEC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;Q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