@torrent-tv/proxy 2.9.74 → 2.9.76
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 +379 -369
- package/bin/cli.js +8 -0
- package/package.json +1 -1
- package/server.js +229 -228
- package/services/piece-store/shared-piece-store.js +107 -6
- package/services/torrent-worker/channel.js +12 -0
- package/services/torrent-worker/client.js +275 -264
- package/services/torrent-worker/pool-adapter.js +179 -179
- package/services/torrent-worker/worker.js +49 -2
- package/test/shared-piece-store.test.js +76 -0
- package/test/worker-channel.test.js +56 -1
|
@@ -1,264 +1,275 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Main-thread face of the torrent worker.
|
|
3
|
-
*
|
|
4
|
-
* Presents the same operations the routes and session manager already use, so
|
|
5
|
-
* moving the torrent to its own thread does not ripple through calling code.
|
|
6
|
-
* The one unavoidable change is that torrents are named by `sourceKey` instead
|
|
7
|
-
* of passed around as objects — objects cannot cross a thread boundary, and
|
|
8
|
-
* pretending otherwise would mean copying them on every call.
|
|
9
|
-
*
|
|
10
|
-
* Reads come back as an ordinary `ReadableStream`, so `/stream` and the codec
|
|
11
|
-
* probe consume them exactly as they consume WebTorrent's own streams today.
|
|
12
|
-
* What that hides is the part that matters: chunks arrive as transferred
|
|
13
|
-
* buffers, never copied — 5.3 ms per 10 MB against 37 ms if cloned and 104 ms
|
|
14
|
-
* through a transferable stream (measured 2026-08-02, see `protocol.js`).
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Worker } from "node:worker_threads";
|
|
18
|
-
import { Readable } from "node:stream";
|
|
19
|
-
import { fileURLToPath } from "node:url";
|
|
20
|
-
import { logger } from "../../utils/logger.js";
|
|
21
|
-
import { createCaller, createReceiveStream } from "./channel.js";
|
|
22
|
-
import { Command, Event } from "./protocol.js";
|
|
23
|
-
|
|
24
|
-
const WORKER_URL = new URL("./worker.js", import.meta.url);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Runs the torrent client on its own thread and exposes it to the main thread.
|
|
28
|
-
*
|
|
29
|
-
* Why this exists at all: profiling during a live seek found the main thread
|
|
30
|
-
* ~85% busy with WebTorrent (buffer concatenation ~15%, wire updates ~9%,
|
|
31
|
-
* garbage collection ~5%), while three of four cores idled. Serving a segment
|
|
32
|
-
* queued behind that work, so reading a finished 10 MB file took 12-23 s where
|
|
33
|
-
* handing it to the channel took 125 ms.
|
|
34
|
-
*/
|
|
35
|
-
export class TorrentWorkerClient {
|
|
36
|
-
#worker;
|
|
37
|
-
#caller;
|
|
38
|
-
/** Receive-side handles for in-flight reads, keyed by request id. */
|
|
39
|
-
#reads = new Map();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.#
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
break;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @param {string}
|
|
104
|
-
* @returns {Promise<{ index: number, name: string, path: string, length: number }[]>}
|
|
105
|
-
*/
|
|
106
|
-
async
|
|
107
|
-
return this.#caller.call(Command.
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* @param {string} sourceKey
|
|
114
|
-
* @
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @param {
|
|
125
|
-
* @
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @param {
|
|
136
|
-
* @returns {Promise<
|
|
137
|
-
*/
|
|
138
|
-
async
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* @param {{ sourceKey: string, fileIndex: number,
|
|
146
|
-
* @returns {Promise<
|
|
147
|
-
*/
|
|
148
|
-
async
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* @param {{ sourceKey: string, fileIndex: number,
|
|
156
|
-
* @returns {Promise<
|
|
157
|
-
*/
|
|
158
|
-
async
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Main-thread face of the torrent worker.
|
|
3
|
+
*
|
|
4
|
+
* Presents the same operations the routes and session manager already use, so
|
|
5
|
+
* moving the torrent to its own thread does not ripple through calling code.
|
|
6
|
+
* The one unavoidable change is that torrents are named by `sourceKey` instead
|
|
7
|
+
* of passed around as objects — objects cannot cross a thread boundary, and
|
|
8
|
+
* pretending otherwise would mean copying them on every call.
|
|
9
|
+
*
|
|
10
|
+
* Reads come back as an ordinary `ReadableStream`, so `/stream` and the codec
|
|
11
|
+
* probe consume them exactly as they consume WebTorrent's own streams today.
|
|
12
|
+
* What that hides is the part that matters: chunks arrive as transferred
|
|
13
|
+
* buffers, never copied — 5.3 ms per 10 MB against 37 ms if cloned and 104 ms
|
|
14
|
+
* through a transferable stream (measured 2026-08-02, see `protocol.js`).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { Worker } from "node:worker_threads";
|
|
18
|
+
import { Readable } from "node:stream";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
import { logger } from "../../utils/logger.js";
|
|
21
|
+
import { createCaller, createReceiveStream } from "./channel.js";
|
|
22
|
+
import { Command, Event } from "./protocol.js";
|
|
23
|
+
|
|
24
|
+
const WORKER_URL = new URL("./worker.js", import.meta.url);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Runs the torrent client on its own thread and exposes it to the main thread.
|
|
28
|
+
*
|
|
29
|
+
* Why this exists at all: profiling during a live seek found the main thread
|
|
30
|
+
* ~85% busy with WebTorrent (buffer concatenation ~15%, wire updates ~9%,
|
|
31
|
+
* garbage collection ~5%), while three of four cores idled. Serving a segment
|
|
32
|
+
* queued behind that work, so reading a finished 10 MB file took 12-23 s where
|
|
33
|
+
* handing it to the channel took 125 ms.
|
|
34
|
+
*/
|
|
35
|
+
export class TorrentWorkerClient {
|
|
36
|
+
#worker;
|
|
37
|
+
#caller;
|
|
38
|
+
/** Receive-side handles for in-flight reads, keyed by request id. */
|
|
39
|
+
#reads = new Map();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {{ maxDiskBytes?: number, memoryBytes?: number }} [options]
|
|
43
|
+
*/
|
|
44
|
+
constructor({ maxDiskBytes, memoryBytes } = {}) {
|
|
45
|
+
this.#worker = new Worker(fileURLToPath(WORKER_URL), {
|
|
46
|
+
workerData: { maxDiskBytes, memoryBytes }
|
|
47
|
+
});
|
|
48
|
+
this.#caller = createCaller(this.#worker);
|
|
49
|
+
|
|
50
|
+
this.#worker.on("message", (message) => {
|
|
51
|
+
// A failed read must fail its stream. This is checked BEFORE the caller
|
|
52
|
+
// sees the message: until 2.9.76 nothing here handled a read error at
|
|
53
|
+
// all, so the worker's report was dropped as unknown, and because the
|
|
54
|
+
// worker sent the end-of-read marker from its `finally` even when the
|
|
55
|
+
// read had thrown, the reader saw a clean end of file instead. A read
|
|
56
|
+
// that failed before it produced anything simply hung forever.
|
|
57
|
+
if (message?.type === Event.ERROR && this.#reads.has(message.id)) {
|
|
58
|
+
const read = this.#reads.get(message.id);
|
|
59
|
+
this.#reads.delete(message.id);
|
|
60
|
+
read.fail(new Error(message.error ?? "Torrent worker read failed."));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (this.#caller.handleReply(message)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
switch (message?.type) {
|
|
67
|
+
case Event.CHUNK: {
|
|
68
|
+
const bytes = message.bytes;
|
|
69
|
+
this.#reads.get(message.id)?.push(
|
|
70
|
+
new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.length)
|
|
71
|
+
);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case Event.READ_END:
|
|
75
|
+
this.#reads.get(message.id)?.close();
|
|
76
|
+
this.#reads.delete(message.id);
|
|
77
|
+
break;
|
|
78
|
+
case Event.LOG:
|
|
79
|
+
logger.info(`torrent-worker: ${message.message}`);
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
this.#worker.on("error", (error) => {
|
|
87
|
+
logger.error(`torrent-worker crashed: ${error?.message ?? error}`);
|
|
88
|
+
// Fail everything outstanding rather than leaving callers hanging: a dead
|
|
89
|
+
// worker will never answer, and a stalled request is worse than an error
|
|
90
|
+
// the loading flow can retry.
|
|
91
|
+
const reason = new Error("Torrent worker stopped unexpectedly.");
|
|
92
|
+
this.#caller.rejectAll(reason);
|
|
93
|
+
for (const [, read] of this.#reads) {
|
|
94
|
+
read.fail(reason);
|
|
95
|
+
}
|
|
96
|
+
this.#reads.clear();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Add (or join) a torrent and register it under `sourceKey`.
|
|
102
|
+
*
|
|
103
|
+
* @param {{ sourceKey: string, sourceType: "magnet" | "torrent", source: string }} params
|
|
104
|
+
* @returns {Promise<{ infoHash: string, name: string, files: { index: number, name: string, path: string, length: number }[] }>}
|
|
105
|
+
*/
|
|
106
|
+
async addSource({ sourceKey, sourceType, source }) {
|
|
107
|
+
return this.#caller.call(Command.ADD_SOURCE, { sourceKey, sourceType, source });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The torrent's files, as plain data.
|
|
112
|
+
*
|
|
113
|
+
* @param {string} sourceKey
|
|
114
|
+
* @returns {Promise<{ index: number, name: string, path: string, length: number }[]>}
|
|
115
|
+
*/
|
|
116
|
+
async listFiles(sourceKey) {
|
|
117
|
+
return this.#caller.call(Command.LIST_FILES, { sourceKey });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Claim a file so it is not evicted while being read.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} sourceKey
|
|
124
|
+
* @param {number} fileIndex
|
|
125
|
+
* @returns {Promise<void>}
|
|
126
|
+
*/
|
|
127
|
+
async acquireFile(sourceKey, fileIndex) {
|
|
128
|
+
await this.#caller.call(Command.ACQUIRE_FILE, { sourceKey, fileIndex });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Drop a claim taken with {@link acquireFile}.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} sourceKey
|
|
135
|
+
* @param {number} fileIndex
|
|
136
|
+
* @returns {Promise<void>}
|
|
137
|
+
*/
|
|
138
|
+
async releaseFile(sourceKey, fileIndex) {
|
|
139
|
+
await this.#caller.call(Command.RELEASE_FILE, { sourceKey, fileIndex });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Live download figures for the progress display.
|
|
144
|
+
*
|
|
145
|
+
* @param {{ sourceKey: string, fileIndex: number, resumeAnchorByteStart?: number | null }} params
|
|
146
|
+
* @returns {Promise<object>}
|
|
147
|
+
*/
|
|
148
|
+
async getFileStats({ sourceKey, fileIndex, resumeAnchorByteStart = null }) {
|
|
149
|
+
return this.#caller.call(Command.FILE_STATS, { sourceKey, fileIndex, resumeAnchorByteStart });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Reorder piece selection around a read position (seek prioritisation).
|
|
154
|
+
*
|
|
155
|
+
* @param {{ sourceKey: string, fileIndex: number, byteStart: number, windowBytes?: number }} params
|
|
156
|
+
* @returns {Promise<void>}
|
|
157
|
+
*/
|
|
158
|
+
async prioritizeByteRange({ sourceKey, fileIndex, byteStart, windowBytes }) {
|
|
159
|
+
await this.#caller.call(Command.PRIORITIZE, { sourceKey, fileIndex, byteStart, windowBytes });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Pre-fetch the head and tail the codec probe needs.
|
|
164
|
+
*
|
|
165
|
+
* @param {{ sourceKey: string, fileIndex: number, headBytes?: number, tailBytes?: number, timeoutMs?: number }} params
|
|
166
|
+
* @returns {Promise<unknown>}
|
|
167
|
+
*/
|
|
168
|
+
async prefetchFileEdges({ sourceKey, fileIndex, headBytes, tailBytes, timeoutMs }) {
|
|
169
|
+
return this.#caller.call(Command.PREFETCH_EDGES, {
|
|
170
|
+
sourceKey,
|
|
171
|
+
fileIndex,
|
|
172
|
+
headBytes,
|
|
173
|
+
tailBytes,
|
|
174
|
+
timeoutMs
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Read a byte range as a stream.
|
|
180
|
+
*
|
|
181
|
+
* Returns immediately with a stream that fills as chunks arrive; cancelling it
|
|
182
|
+
* (viewer gone, seek superseded) stops the worker reading, so pieces are not
|
|
183
|
+
* fetched for a stream nobody will drain.
|
|
184
|
+
*
|
|
185
|
+
* @param {{ sourceKey: string, fileIndex: number, start?: number | null, end?: number | null }} params
|
|
186
|
+
* @returns {ReadableStream<Uint8Array>}
|
|
187
|
+
*/
|
|
188
|
+
createReadStream({ sourceKey, fileIndex, start = null, end = null }) {
|
|
189
|
+
// Same id sequence as commands — see `nextId` in `channel.js`.
|
|
190
|
+
const readId = this.#caller.nextId();
|
|
191
|
+
const receive = createReceiveStream({
|
|
192
|
+
port: this.#worker,
|
|
193
|
+
requestId: readId,
|
|
194
|
+
onCancel: () => {
|
|
195
|
+
void this.#caller.call(Command.CANCEL_READ, { readId }).catch(() => undefined);
|
|
196
|
+
this.#reads.delete(readId);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
this.#reads.set(readId, receive);
|
|
200
|
+
|
|
201
|
+
// The worker replies to READ_RANGE only once the body is fully sent; a
|
|
202
|
+
// failure before that must surface on the stream, not vanish.
|
|
203
|
+
this.#worker.postMessage({
|
|
204
|
+
command: Command.READ_RANGE,
|
|
205
|
+
id: readId,
|
|
206
|
+
params: { sourceKey, fileIndex, start, end }
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
return receive.stream;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* A stand-in for the WebTorrent torrent object, backed by the worker.
|
|
214
|
+
*
|
|
215
|
+
* Callers already hold a torrent and reach into `torrent.files[i]` — for the
|
|
216
|
+
* length, the name, or a read stream. Handing back an object of the same
|
|
217
|
+
* shape keeps every one of those call sites working unchanged, which matters:
|
|
218
|
+
* they are spread across the stream route, the subtitle route, the playback
|
|
219
|
+
* planner and the health report, and rewriting all of them to thread a
|
|
220
|
+
* `sourceKey` through would be a large change with nothing to show for it.
|
|
221
|
+
*
|
|
222
|
+
* Only what is actually used is provided. Anything else would be a promise we
|
|
223
|
+
* cannot keep — the real object lives on the other thread and its methods are
|
|
224
|
+
* not reachable from here.
|
|
225
|
+
*
|
|
226
|
+
* @param {{ sourceKey: string, sourceType: "magnet" | "torrent", source: string }} params
|
|
227
|
+
* @returns {Promise<{ infoHash: string, name: string, sourceKey: string, files: object[] }>}
|
|
228
|
+
*/
|
|
229
|
+
async getTorrent({ sourceKey, sourceType, source }) {
|
|
230
|
+
const info = await this.addSource({ sourceKey, sourceType, source });
|
|
231
|
+
const client = this;
|
|
232
|
+
return {
|
|
233
|
+
infoHash: info.infoHash,
|
|
234
|
+
name: info.name,
|
|
235
|
+
// Carried so helpers that receive only the torrent can still name it to
|
|
236
|
+
// the worker.
|
|
237
|
+
sourceKey,
|
|
238
|
+
files: info.files.map((file) => ({
|
|
239
|
+
...file,
|
|
240
|
+
/**
|
|
241
|
+
* @param {{ start?: number, end?: number }} [options]
|
|
242
|
+
* @returns {ReadableStream<Uint8Array>}
|
|
243
|
+
*/
|
|
244
|
+
createReadStream(options = {}) {
|
|
245
|
+
// Node stream, not a web one: Fastify replies and the ffmpeg pipe
|
|
246
|
+
// both expect that shape, and every existing call site passes the
|
|
247
|
+
// result straight to one of them. `Readable.fromWeb` adds no copy —
|
|
248
|
+
// it wraps the same buffers.
|
|
249
|
+
return Readable.fromWeb(
|
|
250
|
+
client.createReadStream({
|
|
251
|
+
sourceKey,
|
|
252
|
+
fileIndex: file.index,
|
|
253
|
+
start: options.start ?? null,
|
|
254
|
+
end: options.end ?? null
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}))
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Shut the torrent client down and stop the thread.
|
|
264
|
+
*
|
|
265
|
+
* @returns {Promise<void>}
|
|
266
|
+
*/
|
|
267
|
+
async destroyAll() {
|
|
268
|
+
try {
|
|
269
|
+
await this.#caller.call(Command.DESTROY_ALL, {});
|
|
270
|
+
} catch {
|
|
271
|
+
// Already gone — termination below is what matters.
|
|
272
|
+
}
|
|
273
|
+
await this.#worker.terminate();
|
|
274
|
+
}
|
|
275
|
+
}
|