@torrent-tv/proxy 2.9.22 → 2.9.23
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.25
|
|
2
|
+
|
|
3
|
+
- **Fix**: Cold-start playback no longer fails with "Data channel request timed out". `POST /api/playback-plan` (`playback-planner.getPlan`) used to block up to 60 s waiting for the file header to download for the codec probe — exactly the transport's 60 s request timeout, so a cold torrent (peers still connecting, 0 % header) raced and failed. The planner now takes a short per-request budget (`maxWaitMs`, 8 s from the route): it prioritises the file header and probes, and if the header still isn't down it returns the plan flagged `pending: true` (uncached) instead of blocking. The browser polls again — each call keeps the header prioritised — so no single request approaches the 60 s limit and the existing `/stats` poll keeps showing live peers/speed/% the whole time. Pairs with server 0.8.24 (browser-side poll loop); ship together.
|
|
4
|
+
|
|
1
5
|
## 2.9.24
|
|
2
6
|
|
|
3
7
|
- **New**: IPv6-first support (roadmap step 5a). (1) A second STUN server (`stun.cloudflare.com:3478`, alongside Google's) is added to the ICE config — both have IPv6 (AAAA) records, so when the proxy host has a global IPv6 address it gathers a `srflx` candidate over v6 too. IPv6 has no NAT, so if both the proxy and a (v6-native, e.g. cellular) viewer have global v6, the connection can go **direct** over v6 — sidestepping the whole NAT-traversal machinery. (2) Candidate logging now classifies each candidate by address scope — `v4-private` / `v4-public` / `v6-global` / `v6-ula` / `v6-linklocal` / `v6-loopback` (replaces the old private/public host label) — so the field log shows whether a global IPv6 path is actually being offered and chosen. Audited the candidate path: the proxy already forwards ALL candidates (incl. global v6) and the browser adds them all — nothing was dropping global v6, so no filter fix was needed. NOTE: not verifiable on the dev's proxy (its ISP exposes only ULA v6 `fd…`, no global v6); needs a proxy with global v6 to confirm in the field — the new `v6-global` log tag is there to spot it.
|
package/package.json
CHANGED
|
@@ -35,7 +35,11 @@ export async function handleApiPlaybackPlanPost(req, reply, { playbackPlanner })
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
|
-
|
|
38
|
+
// Short per-request budget: if the file header is not downloaded yet the
|
|
39
|
+
// planner returns quickly with `pending: true` instead of blocking up to
|
|
40
|
+
// the transport's 60 s request timeout. The browser polls again (the header
|
|
41
|
+
// keeps downloading, prioritised on each call). Well under that 60 s limit.
|
|
42
|
+
const plan = await playbackPlanner.getPlan({ sourceKey, fileIndex, userAgent, maxWaitMs: 8_000 });
|
|
39
43
|
return reply.send(plan);
|
|
40
44
|
} catch (error) {
|
|
41
45
|
if (error instanceof Error && error.code === "SOURCE_NOT_FOUND") {
|
|
@@ -167,13 +167,22 @@ export function createPlaybackPlanner({
|
|
|
167
167
|
* Throws with `error.code === "SOURCE_NOT_FOUND"` or `"FILE_NOT_FOUND"`
|
|
168
168
|
* when the source or file cannot be located.
|
|
169
169
|
*
|
|
170
|
+
* When the file header has not downloaded yet (cold torrent, peers still
|
|
171
|
+
* connecting) the codec probe cannot succeed. Rather than block the HTTP
|
|
172
|
+
* response until it can, the planner prioritises the header, probes for at
|
|
173
|
+
* most `maxWaitMs`, and if still undetectable returns a plan flagged
|
|
174
|
+
* `pending: true` (NOT cached). The caller polls again — each call keeps the
|
|
175
|
+
* header prioritised and downloading — until a real plan comes back. This
|
|
176
|
+
* avoids a single long request racing the transport's request timeout.
|
|
177
|
+
*
|
|
170
178
|
* @param {object} params
|
|
171
179
|
* @param {string} params.sourceKey
|
|
172
180
|
* @param {number} params.fileIndex
|
|
173
181
|
* @param {string} [params.userAgent=""]
|
|
174
|
-
* @
|
|
182
|
+
* @param {number} [params.maxWaitMs=60000] - Max time to wait for the header within ONE call.
|
|
183
|
+
* @returns {Promise<PlaybackPlan & { pending?: boolean }>}
|
|
175
184
|
*/
|
|
176
|
-
async getPlan({ sourceKey, fileIndex, userAgent = "" }) {
|
|
185
|
+
async getPlan({ sourceKey, fileIndex, userAgent = "", maxWaitMs = 60_000 }) {
|
|
177
186
|
const cacheKey = `${sourceKey}:${fileIndex}`;
|
|
178
187
|
const cached = cache.get(cacheKey);
|
|
179
188
|
if (cached) {
|
|
@@ -218,7 +227,7 @@ export function createPlaybackPlanner({
|
|
|
218
227
|
// file, and an unsupported codec like xvid gets copied → black video.
|
|
219
228
|
await torrentPool.prefetchFileEdges(torrent, fileIndex);
|
|
220
229
|
let probe = await probeStreamCodecs({ ffmpegBin, inputUrl: directUrl, userAgent });
|
|
221
|
-
const probeDeadline = Date.now() +
|
|
230
|
+
const probeDeadline = Date.now() + Math.max(0, maxWaitMs);
|
|
222
231
|
let attempt = 0;
|
|
223
232
|
while (
|
|
224
233
|
probe.audioCodec.length === 0 &&
|
|
@@ -248,11 +257,14 @@ export function createPlaybackPlanner({
|
|
|
248
257
|
};
|
|
249
258
|
// Only cache a plan whose codecs were actually detected. An empty probe is
|
|
250
259
|
// a "header not downloaded yet" signal, not a valid result — caching it
|
|
251
|
-
// would permanently mis-plan the file.
|
|
260
|
+
// would permanently mis-plan the file. In that case flag the plan
|
|
261
|
+
// `pending` so the caller polls again (the header keeps downloading,
|
|
262
|
+
// prioritised by the prefetch above).
|
|
252
263
|
if (codecsDetected) {
|
|
253
264
|
cache.set(cacheKey, plan);
|
|
265
|
+
return plan;
|
|
254
266
|
}
|
|
255
|
-
return plan;
|
|
267
|
+
return { ...plan, pending: true };
|
|
256
268
|
}
|
|
257
269
|
};
|
|
258
270
|
}
|