@torrent-tv/proxy 2.100.3 → 2.100.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.100.3",
3
+ "version": "2.100.4",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -654,11 +654,17 @@ export class HostLoad {
654
654
  // alone would print something like `ffmpeg=-598%`. Only pids present in
655
655
  // BOTH readings are counted, so a process that came or went contributes
656
656
  // nothing rather than a lie.
657
- const runs = encoding.flatMap((session) => this.#host.liveRunsOf(session)).filter((run) => Number.isInteger(run.process?.pid));
657
+ // Each run's pid and start are read BEFORE the readings are awaited: a run
658
+ // that ends meanwhile drops its process, and read after the await it threw
659
+ // `Cannot read properties of null (reading 'pid')`, seven times in one
660
+ // field session, each losing that reading (r64, torrent-tv/meta#178).
661
+ const runs = encoding.flatMap((session) => this.#host.liveRunsOf(session))
662
+ .filter((run) => Number.isInteger(run.process?.pid))
663
+ .map((run) => ({ pid: run.process.pid, startedAt: run.startedAt }));
658
664
  const [system, endedChildren, ...cpuReadings] = await Promise.all([
659
665
  this.#host.readSystemCpu(),
660
666
  this.#host.readEndedChildrenCpuSeconds?.() ?? null,
661
- ...runs.map((run) => this.#host.readProcessCpuSeconds(run.process.pid))
667
+ ...runs.map((run) => this.#host.readProcessCpuSeconds(run.pid))
662
668
  ]);
663
669
  /** @type {Map<number, number>} */
664
670
  const byPid = new Map();
@@ -667,8 +673,8 @@ export class HostLoad {
667
673
  runs.forEach((run, index) => {
668
674
  const seconds = cpuReadings[index];
669
675
  if (seconds !== null) {
670
- byPid.set(run.process.pid, seconds);
671
- startedAt.set(run.process.pid, run.startedAt);
676
+ byPid.set(run.pid, seconds);
677
+ startedAt.set(run.pid, run.startedAt);
672
678
  }
673
679
  });
674
680
  const sample = {