@camstack/server 1.2.177 → 1.2.179

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.
@@ -48,13 +48,13 @@ const client_1 = require("@trpc/client");
48
48
  const addon_call_gateway_js_1 = require("./addon-call-gateway.js");
49
49
  const addon_row_manifest_1 = require("./addon-row-manifest");
50
50
  const addon_settings_provider_js_1 = require("./addon-settings-provider.js");
51
+ const device_meta_mirror_js_1 = require("./device-meta-mirror.js");
51
52
  const integration_visibility_js_1 = require("./integration-visibility.js");
52
53
  const package_dir_utils_1 = require("./package-dir-utils");
53
54
  const prune_misplaced_addons_js_1 = require("./prune-misplaced-addons.js");
54
55
  const require_cache_js_1 = require("./require-cache.js");
55
56
  const runner_convergence_1 = require("./runner-convergence");
56
57
  const runner_spawn_fanout_js_1 = require("./runner-spawn-fanout.js");
57
- const single_flight_refresh_js_1 = require("./single-flight-refresh.js");
58
58
  /**
59
59
  * Decide whether an in-memory addon entry should be evicted because it is no
60
60
  * longer on disk (the uninstall path in `loadNewAddons`).
@@ -309,6 +309,14 @@ class AddonRegistryService {
309
309
  this.streamProbe = streamProbe;
310
310
  this.logger = this.loggingService.createLogger('AddonRegistry');
311
311
  this.addonLoader = new system_1.AddonLoader(this.loggingService.createLogger('AddonLoader'));
312
+ this.deviceMirror = new device_meta_mirror_js_1.DeviceMetaMirror(async (deviceIds) => this.getBrokerApi().deviceManager.listAll.query({
313
+ projection: 'slim',
314
+ ...(deviceIds === null ? {} : { deviceIds: [...deviceIds] }),
315
+ }), {
316
+ parentDeviceId: (deviceId) => this.deviceRegistry.getById(deviceId)?.parentDeviceId ?? null,
317
+ type: (deviceId) => this.deviceRegistry.getById(deviceId)?.type ?? null,
318
+ location: (deviceId) => this.deviceRegistry.getById(deviceId)?.location ?? null,
319
+ }, this.logger);
312
320
  // Kernel-level addon health monitor — drives the 5-min boot grace
313
321
  // window + aggressive auto-retry loop (60s/120s/300s, never gives
314
322
  // up). Failures and recoveries are recorded by the load + init
@@ -1130,56 +1138,22 @@ class AddonRegistryService {
1130
1138
  // fleet — forked devices included. This is a hub-process, SYNCHRONOUSLY
1131
1139
  // readable mirror of that parentage, refreshed OFF the request path on every
1132
1140
  // device-meta lifecycle event — never a per-call DB query.
1133
- deviceParentMirror = new Map();
1134
- /**
1135
- * Hub-process mirror of each device's persisted `type` + `location`, warmed
1136
- * from the same `listAll({projection:'slim'})` sweep as the parent mirror.
1137
- * Backs the v3 scope-model `types` / `locations` selectors: the enforcement
1138
- * matcher resolves a selector against a device's type/location synchronously,
1139
- * off the request path (D49). Empty for a device the hub has never heard of.
1140
- */
1141
- deviceMetaMirror = new Map();
1142
- /** Parent of a device: the persisted mirror first (covers forked devices),
1143
- * falling back to the live hub registry (covers a hub-local device before the
1144
- * first mirror warm). null when top-level or unknown. */
1145
- parentOfDevice(deviceId) {
1146
- const mirrored = this.deviceParentMirror.get(deviceId);
1147
- if (mirrored !== undefined)
1148
- return mirrored;
1149
- return this.deviceRegistry.getById(deviceId)?.parentDeviceId ?? null;
1150
- }
1141
+ //
1142
+ // The mirror itself, and the rule that decides how much of the fleet one
1143
+ // event may re-read, live in `device-meta-mirror.ts` — with the 4 904-call /
1144
+ // 4 987 368-row boot census that made the rule necessary.
1145
+ deviceMirror;
1151
1146
  /** Persisted `DeviceType` string of a device, or null when unknown. Mirror
1152
1147
  * first (covers forked devices), then the live hub registry. */
1153
- getPersistedType = (deviceId) => {
1154
- const mirrored = this.deviceMetaMirror.get(deviceId);
1155
- if (mirrored !== undefined)
1156
- return mirrored.type;
1157
- return this.deviceRegistry.getById(deviceId)?.type ?? null;
1158
- };
1148
+ getPersistedType = (deviceId) => this.deviceMirror.typeOf(deviceId);
1159
1149
  /** Persisted operator `location` label of a device, or null when unset/unknown. */
1160
- getPersistedLocation = (deviceId) => {
1161
- const mirrored = this.deviceMetaMirror.get(deviceId);
1162
- if (mirrored !== undefined)
1163
- return mirrored.location;
1164
- return this.deviceRegistry.getById(deviceId)?.location ?? null;
1165
- };
1150
+ getPersistedLocation = (deviceId) => this.deviceMirror.locationOf(deviceId);
1166
1151
  /**
1167
1152
  * The whole persisted fleet, slim — id + type + location + parentDeviceId.
1168
1153
  * Fuels the FLEET-wide selector expansion (response projection + `auth.me`
1169
1154
  * counts). Read synchronously off the mirror, never a per-call DB query.
1170
1155
  */
1171
- getPersistedDeviceList = () => {
1172
- const out = [];
1173
- for (const [id, m] of this.deviceMetaMirror) {
1174
- out.push({
1175
- id,
1176
- type: m.type,
1177
- location: m.location,
1178
- parentDeviceId: this.deviceParentMirror.get(id) ?? null,
1179
- });
1180
- }
1181
- return out;
1182
- };
1156
+ getPersistedDeviceList = () => this.deviceMirror.list();
1183
1157
  /**
1184
1158
  * Ancestor chain (parent, grandparent, …) of a device, bounded to 8 hops
1185
1159
  * (defence-in-depth against a corrupt registry cycle). Synchronous — it is
@@ -1187,81 +1161,31 @@ class AddonRegistryService {
1187
1161
  * a FORKED camera covers its accessory children. Empty for a top-level device
1188
1162
  * or one the hub has never heard of.
1189
1163
  */
1190
- getPersistedAncestors = (deviceId) => {
1191
- const out = [];
1192
- let current = deviceId;
1193
- for (let hop = 0; hop < 8; hop++) {
1194
- const parent = this.parentOfDevice(current);
1195
- if (parent == null || parent === current)
1196
- break;
1197
- out.push(parent);
1198
- current = parent;
1199
- }
1200
- return out;
1201
- };
1202
- /** One full-fleet rebuild in flight, at most one queued behind it. Every
1203
- * event below asks for the SAME total rebuild, so running it once per event
1204
- * was ~1 000 rebuilds of a 974-row mirror on a boot — each one a 625 KB read
1205
- * and parse on hub-main's event loop. No timer: the first event still
1206
- * refreshes immediately, because this mirror backs scope enforcement.
1207
- * See `single-flight-refresh.ts`. */
1208
- deviceMirrorGate = (0, single_flight_refresh_js_1.createSingleFlightRefresh)(() => this.refreshDeviceParentMirror());
1209
- /** Subscribe the mirror to every device-meta lifecycle event, and warm it once
1210
- * the addon set (device-manager included) is up. */
1164
+ getPersistedAncestors = (deviceId) => this.deviceMirror.ancestorsOf(deviceId);
1165
+ /**
1166
+ * Subscribe the mirror to every device-meta lifecycle event, and warm it once
1167
+ * the addon set (device-manager included) is up.
1168
+ *
1169
+ * The device events ask for a SCOPED refresh — the one device they name, or
1170
+ * nothing at all when they name a field the mirror does not hold.
1171
+ * `SystemAddonsReady` is the only fleet-wide read, and it is also the D8
1172
+ * reconcile: whatever a dropped event would have left stale, the warm
1173
+ * repairs.
1174
+ */
1211
1175
  wireDeviceParentMirror() {
1212
- const refresh = () => {
1213
- void this.deviceMirrorGate.request();
1214
- };
1215
1176
  for (const category of [
1216
1177
  types_1.EventCategory.DeviceMetaChanged,
1217
1178
  types_1.EventCategory.DeviceRegistered,
1218
1179
  types_1.EventCategory.DeviceUnregistered,
1219
1180
  types_1.EventCategory.DeviceProvisioned,
1220
- types_1.EventCategory.SystemAddonsReady,
1221
1181
  ]) {
1222
- this.eventBusService.subscribe({ category }, refresh);
1223
- }
1224
- }
1225
- /** Rebuild the parent mirror from the device-manager's persisted fleet
1226
- * (`listAll`, slim projection — no config blob). Off the request path; a
1227
- * failed read KEEPS the previous mirror (D49 — a read that fails changes
1228
- * nothing, and must never look like an unbind that destroys inheritance). */
1229
- async refreshDeviceParentMirror() {
1230
- try {
1231
- const api = this.getBrokerApi();
1232
- const rows = await api.deviceManager.listAll.query({ projection: 'slim' });
1233
- if (!Array.isArray(rows))
1234
- return;
1235
- const nextParents = new Map();
1236
- const nextMeta = new Map();
1237
- for (const row of rows) {
1238
- if (row === null || typeof row !== 'object')
1239
- continue;
1240
- const id = Reflect.get(row, 'id');
1241
- if (typeof id !== 'number')
1242
- continue;
1243
- const parent = Reflect.get(row, 'parentDeviceId');
1244
- if (typeof parent === 'number')
1245
- nextParents.set(id, parent);
1246
- const type = Reflect.get(row, 'type');
1247
- const location = Reflect.get(row, 'location');
1248
- nextMeta.set(id, {
1249
- type: typeof type === 'string' ? type : '',
1250
- location: typeof location === 'string' ? location : null,
1251
- });
1252
- }
1253
- this.deviceParentMirror.clear();
1254
- for (const [k, v] of nextParents)
1255
- this.deviceParentMirror.set(k, v);
1256
- this.deviceMetaMirror.clear();
1257
- for (const [k, v] of nextMeta)
1258
- this.deviceMetaMirror.set(k, v);
1259
- }
1260
- catch (err) {
1261
- this.logger.debug('device-parent mirror refresh failed — keeping previous', {
1262
- meta: { error: (0, types_1.errMsg)(err) },
1182
+ this.eventBusService.subscribe({ category }, (event) => {
1183
+ this.deviceMirror.onDeviceEvent(event.data);
1263
1184
  });
1264
1185
  }
1186
+ this.eventBusService.subscribe({ category: types_1.EventCategory.SystemAddonsReady }, () => {
1187
+ void this.deviceMirror.refreshAll();
1188
+ });
1265
1189
  }
1266
1190
  /** Load persisted collection disabled-lists from settings-store into the registry */
1267
1191
  loadCollectionPreferences() {
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ /**
3
+ * The hub-process mirror of every device's persisted `parentDeviceId`, `type`
4
+ * and `location` — and the rule that decides how much of the fleet a device
5
+ * event is allowed to make it re-read.
6
+ *
7
+ * ## Why the mirror exists at all
8
+ *
9
+ * The scope matcher's parent→child accessory inheritance (`getDeviceAncestors`
10
+ * in `trpc.context.ts`) needs a deviceId's ancestor chain on EVERY scoped
11
+ * request, synchronously. The hub `DeviceRegistry` only knows devices
12
+ * registered IN the hub process, so it is EMPTY for every forked provider
13
+ * (reolink, hikvision, …): a grant on a forked camera never reached its
14
+ * siren/floodlight/PIR children (measured 0/6 providers inherited). The
15
+ * authoritative parentage lives in the device-manager's persisted meta.
16
+ *
17
+ * ## The number this file exists to explain
18
+ *
19
+ * `FleetReadCensus` on the live hub, 120-second boot window, 2026-08-27
20
+ * (four consecutive boots, 4 886 / 4 904 / 4 910 / 4 960):
21
+ *
22
+ * site DeviceRowStore.list < DeviceRowStore.listFleet < listAll
23
+ * calls 4 904 rows 4 987 368 perMin 2 451
24
+ *
25
+ * 4 987 368 ÷ 4 904 = **1 017.0** — the whole fleet, every single call. The
26
+ * same census puts the boot's device count at 1 017 and the per-device chains
27
+ * (`allocateDeviceId`, `getChildren`) at ~1 024 calls each, so this site is
28
+ * ~4.8 reads per device.
29
+ *
30
+ * The refresh was already single-flighted (`single-flight-refresh.ts`) and
31
+ * that was not enough, because single-flight bounds CONCURRENCY, not RATE: the
32
+ * follow-up starts the instant the previous run ends, so a burst that keeps
33
+ * producing events for two minutes produces rebuilds for two minutes. The
34
+ * missing bound is not a timer — it is the observation that **a mirror of
35
+ * three fields must not re-read a thousand rows because one device's `name`
36
+ * changed.** Two rules, both here:
37
+ *
38
+ * 1. An event that names a meta `field` this mirror does not hold changes
39
+ * nothing, and asks for nothing ({@link MIRROR_IRRELEVANT_META_FIELDS}).
40
+ * 2. An event that does change something changes it for ONE device, so the
41
+ * re-read is `listAll({ deviceIds: [that one] })` — the narrow read
42
+ * `device-queries.ts#listAll` has supported since the linked-devices panel
43
+ * needed it. Only the boot warm (`SystemAddonsReady`) reads the fleet.
44
+ *
45
+ * ## Why the irrelevant-field list is a DENY list
46
+ *
47
+ * The tempting shape is an allow list of the fields the mirror holds
48
+ * (`location`, `type`). It is the wrong direction: a field added to
49
+ * `device-meta-actions.ts` later would silently stop being mirrored, and the
50
+ * symptom is a grant that quietly does not apply. A deny list fails the other
51
+ * way — an unrecognised field costs ONE row and stays correct. The list only
52
+ * ever needs to grow, and growing it late costs a row, not a bug.
53
+ *
54
+ * ## What a scoped refresh must still do
55
+ *
56
+ * A full rebuild removed a device that had disappeared, because it replaced
57
+ * the map. A scoped one must do that explicitly: an id that was asked for and
58
+ * did NOT come back is gone from the mirror — never a fabricated row, the same
59
+ * contract `DeviceRowStore.getMany` states for a fleet it does not know. A
60
+ * read that THROWS is not that: it changes nothing at all (D49).
61
+ */
62
+ Object.defineProperty(exports, "__esModule", { value: true });
63
+ exports.DeviceMetaMirror = exports.MIRROR_IRRELEVANT_META_FIELDS = void 0;
64
+ exports.classifyDeviceEvent = classifyDeviceEvent;
65
+ const types_1 = require("@camstack/types");
66
+ const single_flight_refresh_js_1 = require("./single-flight-refresh.js");
67
+ /**
68
+ * Meta fields a `DeviceMetaChanged` can name that this mirror provably does
69
+ * not hold. Enumerated from every `field:` literal `device-meta-actions.ts`
70
+ * emits; `location` and `type` are deliberately ABSENT because those two are
71
+ * the mirror.
72
+ */
73
+ exports.MIRROR_IRRELEVANT_META_FIELDS = new Set([
74
+ 'name',
75
+ 'disabled',
76
+ 'metadata',
77
+ 'display',
78
+ 'role',
79
+ 'integrationId',
80
+ 'linkDeviceId',
81
+ 'primaryChildEntityId',
82
+ 'childLayout',
83
+ ]);
84
+ /**
85
+ * Classify one device-lifecycle event's payload.
86
+ *
87
+ * `none` only for a payload that NAMES a field the mirror does not hold —
88
+ * that is a claim about the event, not a guess about the device. A payload
89
+ * this cannot read at all falls back to `fleet`: an unparseable event must
90
+ * never silently skip a refresh, because the failure mode is an authorisation
91
+ * mirror that quietly stops converging.
92
+ */
93
+ function classifyDeviceEvent(data) {
94
+ if (data === null || typeof data !== 'object')
95
+ return { kind: 'fleet' };
96
+ const field = Reflect.get(data, 'field');
97
+ if (typeof field === 'string' && exports.MIRROR_IRRELEVANT_META_FIELDS.has(field)) {
98
+ return { kind: 'none' };
99
+ }
100
+ const deviceId = Reflect.get(data, 'deviceId');
101
+ if (typeof deviceId !== 'number' || !Number.isFinite(deviceId))
102
+ return { kind: 'fleet' };
103
+ return { kind: 'device', deviceId };
104
+ }
105
+ /** Max ancestor hops — defence-in-depth against a corrupt parent cycle. */
106
+ const MAX_ANCESTOR_HOPS = 8;
107
+ class DeviceMetaMirror {
108
+ read;
109
+ live;
110
+ logger;
111
+ parents = new Map();
112
+ meta = new Map();
113
+ gate;
114
+ constructor(read, live, logger) {
115
+ this.read = read;
116
+ this.live = live;
117
+ this.logger = logger;
118
+ this.gate = (0, single_flight_refresh_js_1.createSingleFlightRefresh)((scope) => this.refresh(scope));
119
+ }
120
+ /** Ask for a refresh covering exactly what the event changed. */
121
+ onDeviceEvent(data) {
122
+ const scope = classifyDeviceEvent(data);
123
+ if (scope.kind === 'none')
124
+ return;
125
+ void this.gate.request(scope.kind === 'fleet' ? null : new Set([scope.deviceId]));
126
+ }
127
+ /** Warm (or re-warm) the whole fleet — the boot sweep, and the D8 reconcile
128
+ * that repairs anything a dropped event would have left behind. */
129
+ async refreshAll() {
130
+ await this.gate.request(null);
131
+ }
132
+ /** Parent of a device: mirror first (covers forked devices), then the live
133
+ * hub registry (covers a hub-local device before the first warm). */
134
+ parentOf(deviceId) {
135
+ const mirrored = this.parents.get(deviceId);
136
+ if (mirrored !== undefined)
137
+ return mirrored;
138
+ return this.live.parentDeviceId(deviceId);
139
+ }
140
+ /** Persisted `DeviceType` string, or null when unknown. */
141
+ typeOf(deviceId) {
142
+ const mirrored = this.meta.get(deviceId);
143
+ if (mirrored !== undefined)
144
+ return mirrored.type;
145
+ return this.live.type(deviceId);
146
+ }
147
+ /** Persisted operator `location` label, or null when unset/unknown. */
148
+ locationOf(deviceId) {
149
+ const mirrored = this.meta.get(deviceId);
150
+ if (mirrored !== undefined)
151
+ return mirrored.location;
152
+ return this.live.location(deviceId);
153
+ }
154
+ /** The whole mirrored fleet — fuels fleet-wide selector expansion. */
155
+ list() {
156
+ const out = [];
157
+ for (const [id, m] of this.meta) {
158
+ out.push({
159
+ id,
160
+ type: m.type,
161
+ location: m.location,
162
+ parentDeviceId: this.parents.get(id) ?? null,
163
+ });
164
+ }
165
+ return out;
166
+ }
167
+ /** Ancestor chain (parent, grandparent, …), bounded. Empty for a top-level
168
+ * device or one the hub has never heard of. */
169
+ ancestorsOf(deviceId) {
170
+ const out = [];
171
+ let current = deviceId;
172
+ for (let hop = 0; hop < MAX_ANCESTOR_HOPS; hop++) {
173
+ const parent = this.parentOf(current);
174
+ if (parent === null || parent === current)
175
+ break;
176
+ out.push(parent);
177
+ current = parent;
178
+ }
179
+ return out;
180
+ }
181
+ async refresh(scope) {
182
+ try {
183
+ const ids = scope === null ? null : [...scope];
184
+ const rows = await this.read(ids);
185
+ if (!Array.isArray(rows))
186
+ return;
187
+ const nextParents = new Map();
188
+ const nextMeta = new Map();
189
+ for (const row of rows) {
190
+ if (row === null || typeof row !== 'object')
191
+ continue;
192
+ const id = Reflect.get(row, 'id');
193
+ if (typeof id !== 'number')
194
+ continue;
195
+ const parent = Reflect.get(row, 'parentDeviceId');
196
+ if (typeof parent === 'number')
197
+ nextParents.set(id, parent);
198
+ const type = Reflect.get(row, 'type');
199
+ const location = Reflect.get(row, 'location');
200
+ nextMeta.set(id, {
201
+ type: typeof type === 'string' ? type : '',
202
+ location: typeof location === 'string' ? location : null,
203
+ });
204
+ }
205
+ if (ids === null) {
206
+ this.parents.clear();
207
+ for (const [k, v] of nextParents)
208
+ this.parents.set(k, v);
209
+ this.meta.clear();
210
+ for (const [k, v] of nextMeta)
211
+ this.meta.set(k, v);
212
+ return;
213
+ }
214
+ // Scoped: apply exactly the ids that were ASKED for. An id the fleet did
215
+ // not answer with is gone — the one thing the full rebuild used to do
216
+ // implicitly by replacing the map.
217
+ for (const id of ids) {
218
+ const m = nextMeta.get(id);
219
+ if (m === undefined) {
220
+ this.parents.delete(id);
221
+ this.meta.delete(id);
222
+ continue;
223
+ }
224
+ this.meta.set(id, m);
225
+ const parent = nextParents.get(id);
226
+ if (parent === undefined)
227
+ this.parents.delete(id);
228
+ else
229
+ this.parents.set(id, parent);
230
+ }
231
+ }
232
+ catch (err) {
233
+ this.logger.debug('device-meta mirror refresh failed — keeping previous', {
234
+ meta: { error: (0, types_1.errMsg)(err), scope: scope === null ? 'fleet' : scope.size },
235
+ });
236
+ }
237
+ }
238
+ }
239
+ exports.DeviceMetaMirror = DeviceMetaMirror;
@@ -1,32 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSingleFlightRefresh = createSingleFlightRefresh;
4
+ /** Union of two scopes. `null` (everything) absorbs. */
5
+ function widenScope(a, b) {
6
+ if (a === null || b === null)
7
+ return null;
8
+ const out = new Set(a);
9
+ for (const id of b)
10
+ out.add(id);
11
+ return out;
12
+ }
4
13
  /**
5
- * @param run the total rebuild. Called with no arguments, never concurrently
6
- * with itself.
14
+ * @param run the rebuild, given the scope it must cover. Never called
15
+ * concurrently with itself, and never called with an empty set.
7
16
  */
8
17
  function createSingleFlightRefresh(run) {
9
18
  let inFlight = null;
10
- // Set while a run is active and another request arrived. One flag, not a
11
- // counter: N requests during one run need exactly ONE follow-up between
12
- // them, because the follow-up reads the world as it is when it starts.
13
- let pending = false;
19
+ // The union of everything requested while a run is active — `undefined` when
20
+ // nothing is pending. One accumulator, not a queue: N requests during one run
21
+ // need exactly ONE follow-up between them, because the follow-up reads the
22
+ // world as it is when it starts.
23
+ let pendingScope;
14
24
  let pendingPromise = null;
15
25
  let releasePending = () => { };
16
- const start = () => {
26
+ const start = (scope) => {
17
27
  const active = (async () => {
18
28
  try {
19
- await run();
29
+ await run(scope);
20
30
  }
21
31
  finally {
22
32
  inFlight = null;
23
- if (pending) {
24
- pending = false;
33
+ if (pendingScope !== undefined) {
34
+ const next = pendingScope;
35
+ pendingScope = undefined;
25
36
  const release = releasePending;
26
37
  releasePending = () => { };
27
38
  pendingPromise = null;
28
39
  // Chain the follow-up, then settle everyone who waited for it.
29
- void start().finally(release);
40
+ void start(next).finally(release);
30
41
  }
31
42
  }
32
43
  })();
@@ -34,18 +45,20 @@ function createSingleFlightRefresh(run) {
34
45
  return active;
35
46
  };
36
47
  return {
37
- request: async () => {
48
+ request: async (scope) => {
49
+ if (scope !== null && scope.size === 0)
50
+ return;
38
51
  if (inFlight === null) {
39
- await start();
52
+ await start(scope);
40
53
  return;
41
54
  }
42
- if (!pending) {
43
- pending = true;
55
+ pendingScope = pendingScope === undefined ? scope : widenScope(pendingScope, scope);
56
+ if (pendingPromise === null) {
44
57
  pendingPromise = new Promise((resolve) => {
45
58
  releasePending = resolve;
46
59
  });
47
60
  }
48
- // `pendingPromise` is non-null whenever `pending` is set; the local
61
+ // `pendingPromise` is non-null whenever a scope is pending; the local
49
62
  // binding keeps that visible to the type checker after the await.
50
63
  const wait = pendingPromise;
51
64
  if (wait !== null)
package/dist/main.js CHANGED
@@ -241,7 +241,12 @@ async function bootstrap() {
241
241
  // heartbeat then behaves exactly as it did before.
242
242
  const heapReclaimer = (0, system_1.createV8Reclaimer)();
243
243
  const heapReclaim = heapReclaimer === undefined ? undefined : { reclaim: heapReclaimer };
244
- (0, system_1.startHeapWatch)('hub-main', undefined, undefined, heapReclaim);
244
+ // ...and the budget the heartbeat alarms on. hub-main has no manifest to declare one in, and
245
+ // the entrypoint that would be the obvious alternative is the least deployable surface here —
246
+ // the image never carries this repo's backend. So the number lives in `@camstack/server`,
247
+ // which is what `applyServerUpdate` replaces, for exactly the reason the heartbeat itself is
248
+ // started from this file. See `hubMainRssBudget` for why 4096, and why it is expected to fire.
249
+ (0, system_1.startHeapWatch)('hub-main', undefined, undefined, heapReclaim, undefined, undefined, true, (0, system_1.hubMainRssBudget)());
245
250
  // Clean up orphaned processes from previous crashes before starting
246
251
  cleanupOrphanProcesses();
247
252
  // SPA fallback — set later when admin UI is resolved, used by addon route catch-all
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.177",
3
+ "version": "1.2.179",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",