@torrent-tv/proxy 2.9.38 → 2.9.39

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.9.39
2
+
3
+ - **Chore**: Log the stack (first frames) of WebTorrent `warning` events, not just the message. Field diagnosis: a playback froze mid-file with repeated `torrent-pool: … warning: Connection error: Cannot read properties of null (reading 'type')` (a WebTorrent µTP null-peer NPE, webtorrent#1932/#1940) while the swarm had seeders — peer connections were failing and the download starved. The old handler logged only the terse message, hiding which library path threw; the stack pinpoints it before we mitigate (next: prefer HTTP/DHT over the timing-out UDP trackers, then consider disabling µTP).
4
+
1
5
  ## 2.9.38
2
6
 
3
7
  - **New**: Adaptive bitrate for thin viewer links (OpenSpec change `adaptive-bitrate`). Field evidence (iPhone on cellular): uncapped complex scenes produced 4 s segments of ~18 Mbit/s against a 1–6 Mbit/s link — 45 s prebuffer and a draining buffer. Two parts. (a) Software encodes are now constrained-CRF: `-maxrate`/`-bufsize` per resolution rung (1080p→5000K, 720p→2800K, 480p→1400K, 360p→800K, 240p→400K nominal; ×1.3/×1.5 — webtor's production multipliers), so peaks stay bounded. (b) New data-channel route `POST /api/transcode-sessions/:id/net-report` accepts the browser's measured link throughput + buffered seconds; the realtime-budget loop gains a second downshift trigger — a FRESH report showing the usable link (×0.8 safety) sustainedly (15 s) below the observed produced bitrate while the viewer's buffer is low (<10 s) steps the encode one rung down via the existing machinery (shared 30 s cooldown, step cap, no upswitch). Log reason `viewer-link-bound` distinguishes it from CPU downshifts. Manual-quality sessions are exempt (no budget ladder); old clients that never report simply keep today's behaviour plus the caps.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.9.38",
3
+ "version": "2.9.39",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {
@@ -49,6 +49,24 @@ const DISK_CAP_SWEEP_INTERVAL_MS = 30_000;
49
49
  * asked to hold more than it can). Best-effort; falls back to the fixed max
50
50
  * when the filesystem cannot be stat'd.
51
51
  *
52
+ * Format a WebTorrent warning for logging: message plus a bounded stack.
53
+ * WebTorrent surfaces internal peer-connection failures (e.g. the µTP
54
+ * null-peer NPEs, webtorrent#1932/#1940) as non-fatal "warning" events
55
+ * carrying only a terse message; the stack pinpoints the exact library path,
56
+ * so we log the first few frames to diagnose which failure it is.
57
+ *
58
+ * @param {unknown} warning
59
+ * @returns {string}
60
+ */
61
+ function formatWarning(warning) {
62
+ if (!(warning instanceof Error)) {
63
+ return String(warning);
64
+ }
65
+ const stack = typeof warning.stack === "string" ? warning.stack.split("\n").slice(0, 4).join(" | ") : "";
66
+ return stack || warning.message;
67
+ }
68
+
69
+ /**
52
70
  * @param {string} storePath
53
71
  * @returns {number}
54
72
  */
@@ -162,8 +180,7 @@ export class TorrentPool {
162
180
  logger.error(`WebTorrent client error: ${error.message}`);
163
181
  });
164
182
  this.client.on("warning", (warning) => {
165
- const message = warning instanceof Error ? warning.message : String(warning);
166
- logger.warn(`torrent-pool: client warning: ${message}`);
183
+ logger.warn(`torrent-pool: client warning: ${formatWarning(warning)}`);
167
184
  });
168
185
 
169
186
  this.#maxDiskBytes = Number.isFinite(maxDiskBytes) && maxDiskBytes >= 0
@@ -250,8 +267,7 @@ export class TorrentPool {
250
267
  );
251
268
 
252
269
  torrent.on("warning", (warning) => {
253
- const message = warning instanceof Error ? warning.message : String(warning);
254
- logger.warn(`torrent-pool: [${label}] warning: ${message}`);
270
+ logger.warn(`torrent-pool: [${label}] warning: ${formatWarning(warning)}`);
255
271
  });
256
272
 
257
273
  // bittorrent-tracker's Client emits "update" with each announce response.