@camstack/server 1.2.185 → 1.2.186
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.
- package/dist/main.js +32 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -239,6 +239,15 @@ async function bootstrap() {
|
|
|
239
239
|
// 256KB pages it committed at a sawtooth peak, and an ordinary major GC does not
|
|
240
240
|
// return them. `createV8Reclaimer()` returns undefined if V8 declines, and the
|
|
241
241
|
// heartbeat then behaves exactly as it did before.
|
|
242
|
+
//
|
|
243
|
+
// What it recovers, and what it does NOT: the reclaimer is
|
|
244
|
+
// `gc({ execution: 'sync', flavor: 'last-resort' })` — V8 and only V8. It hands back the
|
|
245
|
+
// 256KB pages V8 committed at a sawtooth peak, which on 2026-08-27 was ~1.3GB of a 4.87GiB
|
|
246
|
+
// process. The other ~2.8GB, spread across 13 anonymous mappings >=64MB, is glibc memory
|
|
247
|
+
// already freed by the allocator and never returned to the kernel; nothing in this repository
|
|
248
|
+
// calls `malloc_trim`, and no V8 flavor reaches it. So the pass is a real bound on the V8
|
|
249
|
+
// share and touches none of the share that grew. It is telemetry plus a partial bound, not a
|
|
250
|
+
// fix — do not read a reclaim line as "the leak was handled".
|
|
242
251
|
const heapReclaimer = (0, system_1.createV8Reclaimer)();
|
|
243
252
|
const heapReclaim = heapReclaimer === undefined ? undefined : { reclaim: heapReclaimer };
|
|
244
253
|
// ...and the budget the heartbeat alarms on. hub-main has no manifest to declare one in, and
|
|
@@ -246,7 +255,14 @@ async function bootstrap() {
|
|
|
246
255
|
// the image never carries this repo's backend. So the number lives in `@camstack/server`,
|
|
247
256
|
// which is what `applyServerUpdate` replaces, for exactly the reason the heartbeat itself is
|
|
248
257
|
// started from this file. See `hubMainRssBudget` for why 4096, and why it is expected to fire.
|
|
249
|
-
|
|
258
|
+
//
|
|
259
|
+
// The sink is DEFERRED. Started here, before any logger exists, the heartbeat could only ever
|
|
260
|
+
// reach `console.log` — which is not a log destination, so for 42 hours Loki carried a `[mem]`
|
|
261
|
+
// line for every runner in the cluster and none for the largest process in it. The sink is
|
|
262
|
+
// repointed at `LoggingService` the moment it exists (below), and boot lines keep going to
|
|
263
|
+
// stdout exactly as before. See `createDeferredHeapWatchSink`.
|
|
264
|
+
const heapWatchSink = (0, system_1.createDeferredHeapWatchSink)(system_1.HUB_MAIN_HEAP_WATCH_LABEL);
|
|
265
|
+
(0, system_1.startHeapWatch)(system_1.HUB_MAIN_HEAP_WATCH_LABEL, heapWatchSink.sink, undefined, heapReclaim, undefined, undefined, true, (0, system_1.hubMainRssBudget)());
|
|
250
266
|
// Clean up orphaned processes from previous crashes before starting
|
|
251
267
|
cleanupOrphanProcesses();
|
|
252
268
|
// SPA fallback — set later when admin UI is resolved, used by addon route catch-all
|
|
@@ -334,6 +350,21 @@ async function bootstrap() {
|
|
|
334
350
|
// If registration fails, start in degraded mode: serve a health warning endpoint.
|
|
335
351
|
// Instantiate new core services
|
|
336
352
|
const loggingService = app.get(logging_service_1.LoggingService);
|
|
353
|
+
// The heap heartbeat's handover: from here on hub-main's `[mem]` lines go through the log
|
|
354
|
+
// manager like every runner's do — buffer, console destination, rotated file and Loki — so
|
|
355
|
+
// the one process that mediates every cross-runner call is finally trendable next to the
|
|
356
|
+
// runners it forked, in the same vocabulary. Destinations that register later (Loki is an
|
|
357
|
+
// addon, so it does) are replayed the ring buffer, so the lines between here and then ship
|
|
358
|
+
// too. Deliberately the FIRST thing done with `loggingService`.
|
|
359
|
+
const heapWatchLogger = loggingService.createLogger('heap-watch');
|
|
360
|
+
heapWatchSink.attach({
|
|
361
|
+
info: (line) => {
|
|
362
|
+
heapWatchLogger.info(line);
|
|
363
|
+
},
|
|
364
|
+
warn: (line) => {
|
|
365
|
+
heapWatchLogger.warn(line);
|
|
366
|
+
},
|
|
367
|
+
});
|
|
337
368
|
const addonRouteRegistry = new system_1.AddonRouteRegistry();
|
|
338
369
|
const dataPlaneRegistry = new system_1.DataPlaneRegistry();
|
|
339
370
|
// Use Fastify-managed notification/toast wrappers (globally provided by NotificationModule)
|