@hadoku/service-kernel 0.1.180 → 0.1.182

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.
@@ -12,10 +12,7 @@ export interface CapacityDeps {
12
12
  /** Counts for the window, read once as each post goes out; the reader resets its own. */
13
13
  counts?: () => Record<string, unknown>;
14
14
  /** Process memory; `process.memoryUsage` in production. */
15
- memory?: () => {
16
- rss: number;
17
- heapUsed: number;
18
- };
15
+ memory?: () => Pick<NodeJS.MemoryUsage, 'rss' | 'heapUsed'> & Partial<NodeJS.MemoryUsage>;
19
16
  /** A request path counted on its own, under `uncountedField`, never timed. Default: none. */
20
17
  uncountedPath?: (path: string) => boolean;
21
18
  /** The capacity event's field for `uncountedPath`'s count. Default: `'uncounted'`. */
@@ -42,6 +42,10 @@ export function capacitySampler(deps) {
42
42
  ...Object.fromEntries(Object.entries(deps.gauges).map(([k, read]) => [k, read()])),
43
43
  rssMb: Math.round(m.rss / MB),
44
44
  heapMb: Math.round(m.heapUsed / MB),
45
+ // What RSS holds beyond the live heap: V8's reservation, Buffers, and native memory behind them.
46
+ ...(m.heapTotal === undefined ? {} : { heapTotalMb: Math.round(m.heapTotal / MB) }),
47
+ ...(m.external === undefined ? {} : { externalMb: Math.round(m.external / MB) }),
48
+ ...(m.arrayBuffers === undefined ? {} : { arrayBuffersMb: Math.round(m.arrayBuffers / MB) }),
45
49
  };
46
50
  for (const [k, v] of Object.entries(reading))
47
51
  peaks[k] = Math.max(peaks[k] ?? v, v);
@@ -113,10 +113,12 @@ export async function createGameServer({ id, config, state, plugins }) {
113
113
  return;
114
114
  }
115
115
  const start = process.hrtime.bigint();
116
+ // Read now: a mounted router strips its prefix from req.path while it routes, so on finish an /api route reads "/".
117
+ const path = req.path;
116
118
  res.on('finish', () => {
117
119
  const ms = Number(process.hrtime.bigint() - start) / 1e6;
118
120
  // The identity the handlers saw, post-sanitize: a spoofed request logs as public.
119
- console.log(JSON.stringify({ t: new Date().toISOString(), svc: id, method: req.method, path: req.path, status: res.statusCode, ms: Math.round(ms), user: userIdOf(req), tier: tierOf(req) }));
121
+ console.log(JSON.stringify({ t: new Date().toISOString(), svc: id, method: req.method, path, status: res.statusCode, ms: Math.round(ms), user: userIdOf(req), tier: tierOf(req) }));
120
122
  });
121
123
  next();
122
124
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/service-kernel",
3
- "version": "0.1.180",
4
- "gitHead": "4810e0ca28ad2237ae513f4b295b9798f67f3994",
3
+ "version": "0.1.182",
4
+ "gitHead": "1dab81fb2c5bc9f8d636c9766b1ca23e2b2bce3f",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The server parts any game keeps: edge auth and the tier gate, base path and bundle check, health and the busy probe, lifecycle, the JSON logger, the state directory, telemetry and capacity, per-caller limits, the browser relays, the erase registry, and createGameServer, which boots a game from its config and plugins. Knows no game; the app binds its service id, prefix and env names. MIT; imports only node built-ins, express, socket.io, platform-wire and @wolffm/*.",
@@ -56,7 +56,7 @@
56
56
  }
57
57
  },
58
58
  "dependencies": {
59
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.147",
59
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.149",
60
60
  "express": "^5.1.0",
61
61
  "socket.io": "^4.8.3"
62
62
  },