next-issue 17.2.7 → 17.2.8
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
|
@@ -34,6 +34,7 @@ export async function startWorker(options) {
|
|
|
34
34
|
const runs = new Map();
|
|
35
35
|
let restart;
|
|
36
36
|
let successor;
|
|
37
|
+
let closing = false;
|
|
37
38
|
const server = createServer();
|
|
38
39
|
const sockets = new WebSocketServer({ server });
|
|
39
40
|
const busy = () => [...runs.values()].some(active);
|
|
@@ -54,6 +55,7 @@ export async function startWorker(options) {
|
|
|
54
55
|
await shutdown(server, sockets, owned, listening);
|
|
55
56
|
};
|
|
56
57
|
const { closed, close } = closer(async () => {
|
|
58
|
+
closing = true;
|
|
57
59
|
clearTimeout(idleTimer);
|
|
58
60
|
const run = runs.get(options.root);
|
|
59
61
|
if (successor !== undefined && run !== undefined && upgradedRun(run)) {
|
|
@@ -114,7 +116,7 @@ export async function startWorker(options) {
|
|
|
114
116
|
joinGoing(socket, refuse, going, argv, id);
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
117
|
-
const refusal = startRefusal(going, restart !== undefined);
|
|
119
|
+
const refusal = startRefusal(going, restart !== undefined, closing);
|
|
118
120
|
if (refusal !== undefined) {
|
|
119
121
|
if (!resume) {
|
|
120
122
|
refuse(refusal);
|
|
@@ -151,6 +153,9 @@ export async function startWorker(options) {
|
|
|
151
153
|
summary = ended;
|
|
152
154
|
},
|
|
153
155
|
}))
|
|
156
|
+
.finally(() => {
|
|
157
|
+
closing = true;
|
|
158
|
+
})
|
|
154
159
|
.then((code) => {
|
|
155
160
|
update({ ...run.progress, status: endStatus(run) });
|
|
156
161
|
return sendAllSent(sockets, {
|
|
@@ -21,10 +21,13 @@ export function endStatus(run) {
|
|
|
21
21
|
}
|
|
22
22
|
return run.stop === undefined ? 'finished' : 'stopped';
|
|
23
23
|
}
|
|
24
|
-
export function startRefusal(run, restart) {
|
|
24
|
+
export function startRefusal(run, restart, closing) {
|
|
25
25
|
if (restart) {
|
|
26
26
|
return 'the worker is restarting, try again soon';
|
|
27
27
|
}
|
|
28
|
+
if (closing) {
|
|
29
|
+
return 'the worker is shutting down, try again soon';
|
|
30
|
+
}
|
|
28
31
|
if (active(run)) {
|
|
29
32
|
return 'a run is going in this repository already';
|
|
30
33
|
}
|