@norskvideo/ctl-sdk 0.1.41 → 0.1.42
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/migration-client.js +14 -2
- package/package.json +1 -1
package/migration-client.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// (1 s doubling to 30 s) after any drop, re-sends hello, and holds at most
|
|
29
29
|
// the LATEST unsent report while disconnected — a newer position supersedes
|
|
30
30
|
// an older one, and the worker acts on the first it hears.
|
|
31
|
-
import { JOB_SOCKET_ENV, parseWorkerToJobFrame, } from "@norskvideo/ctl-product-template-schema/migration-socket";
|
|
31
|
+
import { JOB_SOCKET_ENV, JOB_SOCKET_MAX_FRAME_BYTES, parseWorkerToJobFrame, } from "@norskvideo/ctl-product-template-schema/migration-socket";
|
|
32
32
|
export function stateRefusal(reason) {
|
|
33
33
|
return { refused: true, reason };
|
|
34
34
|
}
|
|
@@ -199,8 +199,20 @@ class SocketMigrationClient {
|
|
|
199
199
|
this.pending = msg;
|
|
200
200
|
}
|
|
201
201
|
send(msg) {
|
|
202
|
+
let frame = JSON.stringify(msg);
|
|
203
|
+
const bytes = new TextEncoder().encode(frame).length;
|
|
204
|
+
if (bytes > JOB_SOCKET_MAX_FRAME_BYTES) {
|
|
205
|
+
// The worker would close the socket on it (frameTooLarge) — for a
|
|
206
|
+
// `source-stopped-output`, with the source's output already stopped —
|
|
207
|
+
// and the migration would wait out its deadline. Say why instead: a
|
|
208
|
+
// `state` becomes a refusal (the source carries on, nothing moved),
|
|
209
|
+
// anything else an abort naming the size.
|
|
210
|
+
const why = `'${msg.type}' is ${bytes} bytes, over the job socket's ${JOB_SOCKET_MAX_FRAME_BYTES}-byte frame limit`;
|
|
211
|
+
this.log(`${why}; not sent`);
|
|
212
|
+
frame = JSON.stringify(msg.type === "state" ? { type: "state-refused", reason: why } : { type: "abort", reason: why });
|
|
213
|
+
}
|
|
202
214
|
try {
|
|
203
|
-
this.socket?.send(
|
|
215
|
+
this.socket?.send(frame);
|
|
204
216
|
}
|
|
205
217
|
catch (e) {
|
|
206
218
|
this.log(`send of '${msg.type}' failed: ${String(e)}`);
|