next-issue 14.4.19 → 14.4.21
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/dist/worker/serve.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { resumeOnSuccessor } from '../shared/worker-client.mjs';
|
|
|
14
14
|
import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
|
|
15
15
|
import { checkSocketPath, workerPaths } from '../shared/worker-paths.mjs';
|
|
16
16
|
import { active, dropUpgrade, endStatus, newRun, requestRefresh, requestStop, requestUpgrade, runControls, runsMessage, setHunting, setWatching, startRefusal, stoppingMessage, stopPoint, switchRefusal, } from './worker-run.mjs';
|
|
17
|
-
import { broadcast, closer, fileId, isLaunch, listen, parseMessage, removeOwned, send, sendAll, shutdown, stopListening, } from './worker-server.mjs';
|
|
17
|
+
import { broadcast, closer, fileId, isLaunch, listen, parseMessage, removeOwned, send, sendAll, sendAllSent, shutdown, stopListening, } from './worker-server.mjs';
|
|
18
18
|
const LOCK_WAIT_MS = 5_000;
|
|
19
19
|
const IDLE_MS = 30_000;
|
|
20
20
|
export async function startWorker(options) {
|
|
@@ -119,7 +119,7 @@ export async function startWorker(options) {
|
|
|
119
119
|
}))
|
|
120
120
|
.then((code) => {
|
|
121
121
|
update({ ...run.progress, status: endStatus(run) });
|
|
122
|
-
|
|
122
|
+
return sendAllSent(sockets, {
|
|
123
123
|
type: 'end',
|
|
124
124
|
root,
|
|
125
125
|
code,
|
|
@@ -127,7 +127,7 @@ export async function startWorker(options) {
|
|
|
127
127
|
});
|
|
128
128
|
}, (error) => {
|
|
129
129
|
update({ ...run.progress, status: 'failed', error: message(error) });
|
|
130
|
-
|
|
130
|
+
return sendAllSent(sockets, { type: 'end', root, code: 1, error: message(error) });
|
|
131
131
|
})
|
|
132
132
|
.finally(() => void close());
|
|
133
133
|
};
|
|
@@ -17,13 +17,10 @@ export function active(run) {
|
|
|
17
17
|
return run?.progress.status === 'running' || run?.progress.status === 'stopping';
|
|
18
18
|
}
|
|
19
19
|
export function endStatus(run) {
|
|
20
|
-
if (run.progress.
|
|
20
|
+
if (run.progress.error !== undefined) {
|
|
21
21
|
return 'failed';
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
return 'stopped';
|
|
25
|
-
}
|
|
26
|
-
return run.progress.error === undefined ? 'finished' : 'failed';
|
|
23
|
+
return run.stop === undefined ? 'finished' : 'stopped';
|
|
27
24
|
}
|
|
28
25
|
export function startRefusal(run, restart) {
|
|
29
26
|
if (restart) {
|
|
@@ -48,6 +48,10 @@ export function sendAll(sockets, value) {
|
|
|
48
48
|
send(socket, value);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
export async function sendAllSent(sockets, value) {
|
|
52
|
+
const text = JSON.stringify(value);
|
|
53
|
+
await Promise.all([...sockets.clients].map((socket) => new Promise((resolve) => socket.send(text, () => resolve()))));
|
|
54
|
+
}
|
|
51
55
|
export function listen(server, path) {
|
|
52
56
|
return new Promise((resolve, reject) => {
|
|
53
57
|
server.once('error', reject);
|