@torrent-tv/proxy 2.9.3 → 2.9.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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/services/data-channel-handler.js +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 2.9.4
|
|
2
|
+
|
|
3
|
+
- **Chore**: Temporary `[net-debug]` instrumentation in `data-channel-handler.js` now splits transfer timing into `fetchMs` (waiting for the local route, incl. ffmpeg segment finalization), `ttfbMs` (time to first body chunk), `sendMs` (channel send duration) and `chunks`, to locate where early-segment latency is spent (transport vs segment production).
|
|
4
|
+
|
|
1
5
|
## 2.9.3
|
|
2
6
|
|
|
3
7
|
- **New**: WebRTC data-channel response bodies are now sent as **binary** frames (`sendMessageBinary`) instead of base64-encoded JSON `response-chunk` messages, removing the ~33% base64 overhead and the JSON encode cost. Frame layout: `[flags(1)][idLen(1)][requestId(ASCII)][payload]`. Control messages (`response-start`, `response-error`, `pong`) remain JSON strings. Requires the matching browser client (server ≥ 0.8.0); **deploy the server before the proxy**.
|
package/package.json
CHANGED
|
@@ -162,6 +162,10 @@ export function createDataChannelHandler({ proxyPort, onLog }) {
|
|
|
162
162
|
const requestHeaders = { ...(forwardedHeaders ?? {}), host: `127.0.0.1:${proxyPort}` };
|
|
163
163
|
|
|
164
164
|
let response;
|
|
165
|
+
// [net-debug] TEMPORARY: time spent in the local fetch (waiting for the
|
|
166
|
+
// route to return a response — e.g. long-polling until an HLS segment is
|
|
167
|
+
// finalized by ffmpeg) vs. the body transfer over the data channel.
|
|
168
|
+
const fetchStartedAt = Date.now();
|
|
165
169
|
try {
|
|
166
170
|
response = await fetch(targetUrl, {
|
|
167
171
|
method,
|
|
@@ -195,7 +199,13 @@ export function createDataChannelHandler({ proxyPort, onLog }) {
|
|
|
195
199
|
try {
|
|
196
200
|
const reader = response.body.getReader();
|
|
197
201
|
// [net-debug] TEMPORARY: measure transfer size/time and channel buffering.
|
|
202
|
+
// fetchMs = time waiting for the route (incl. ffmpeg segment finalization).
|
|
203
|
+
// ttfbMs = time from body-read start to the first chunk with data (loopback).
|
|
204
|
+
// sendMs = total body read+send duration over the data channel.
|
|
205
|
+
const fetchMs = Date.now() - fetchStartedAt;
|
|
198
206
|
const sendStartedAt = Date.now();
|
|
207
|
+
let firstByteMs = -1;
|
|
208
|
+
let chunks = 0;
|
|
199
209
|
let totalBytes = 0;
|
|
200
210
|
let maxBuffered = 0;
|
|
201
211
|
while (true) {
|
|
@@ -206,11 +216,14 @@ export function createDataChannelHandler({ proxyPort, onLog }) {
|
|
|
206
216
|
let bufferedNow = 0;
|
|
207
217
|
try { bufferedNow = typeof channel.bufferedAmount === "function" ? channel.bufferedAmount() : 0; } catch { /* ignore */ }
|
|
208
218
|
log(
|
|
209
|
-
`[net-debug] sent ${path}${queryInfo} bytes=${totalBytes}
|
|
219
|
+
`[net-debug] sent ${path}${queryInfo} bytes=${totalBytes} fetchMs=${fetchMs} ` +
|
|
220
|
+
`ttfbMs=${firstByteMs} sendMs=${elapsedMs} chunks=${chunks} ` +
|
|
210
221
|
`maxBuffered=${maxBuffered} bufferedAtEnd=${bufferedNow}`
|
|
211
222
|
);
|
|
212
223
|
break;
|
|
213
224
|
}
|
|
225
|
+
if (firstByteMs < 0) firstByteMs = Date.now() - sendStartedAt;
|
|
226
|
+
chunks += 1;
|
|
214
227
|
totalBytes += value.length;
|
|
215
228
|
try {
|
|
216
229
|
const b = typeof channel.bufferedAmount === "function" ? channel.bufferedAmount() : 0;
|