next-issue 6.6.77 → 6.6.79
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/README.md +8 -2
- package/dist/exec.mjs +12 -0
- package/dist/progress.mjs +1 -2
- package/dist/serve.mjs +6 -2
- package/dist/worker-log.mjs +36 -0
- package/dist/worker-paths.mjs +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -688,7 +688,8 @@ affect another. The worker:
|
|
|
688
688
|
unknown argument with an `error` message;
|
|
689
689
|
- sends every client the progress of every run when it connects and on every
|
|
690
690
|
change: for each running issue the issue, the step, the tool count and the
|
|
691
|
-
last tool, and the handled issues
|
|
691
|
+
last tool, and the handled issues (an issue handled in more than one pass
|
|
692
|
+
appears once for each);
|
|
692
693
|
- sends every client a `questions` message for each repository: the open
|
|
693
694
|
issues with the `needsHuman` label, each with its number, title, the reason
|
|
694
695
|
of the hand-over, the url of the comment that holds it, the `owner/name`
|
|
@@ -723,7 +724,12 @@ affect another. The worker:
|
|
|
723
724
|
- closes once no run is going when a client with a newer version connects, so
|
|
724
725
|
that the client can start the newer worker;
|
|
725
726
|
- stops every agent and command and exits on `SIGTERM` or `SIGINT`, and
|
|
726
|
-
removes its socket and lock files
|
|
727
|
+
removes its socket and lock files;
|
|
728
|
+
- keeps `.next-issue/worker.log`, where the extension writes the output of
|
|
729
|
+
the worker, within 10 MiB: when it starts and once a minute while it runs,
|
|
730
|
+
it cuts a log of more than 10 MiB to its newest 5 MiB, from the start of a
|
|
731
|
+
line. It skips the cut while a command that writes to the log runs. The
|
|
732
|
+
run logs under `.next-issue/runs/` hold the same events.
|
|
727
733
|
|
|
728
734
|
Stop the worker of a repository with `next-issue stop` in that repository.
|
|
729
735
|
Workers of other repositories carry on. This sends `SIGTERM` to the process in
|
package/dist/exec.mjs
CHANGED
|
@@ -7,6 +7,10 @@ let observer;
|
|
|
7
7
|
const DEFAULT_TIMEOUT_MS = minutesToMs(10);
|
|
8
8
|
const defaultTimeout = new AsyncLocalStorage();
|
|
9
9
|
const STDERR_TAIL = 200_000;
|
|
10
|
+
let shownCommands = 0;
|
|
11
|
+
export function showingCommands() {
|
|
12
|
+
return shownCommands > 0;
|
|
13
|
+
}
|
|
10
14
|
export function setCommandObserver(next) {
|
|
11
15
|
observer = next;
|
|
12
16
|
}
|
|
@@ -66,9 +70,17 @@ export function run(command, args, options = {}) {
|
|
|
66
70
|
const output = collect(child, options);
|
|
67
71
|
const timer = deadline(limit, () => killTree(child));
|
|
68
72
|
let done = false;
|
|
73
|
+
let shown = options.show === true;
|
|
74
|
+
if (shown) {
|
|
75
|
+
shownCommands += 1;
|
|
76
|
+
}
|
|
69
77
|
const release = () => {
|
|
70
78
|
timer.clear();
|
|
71
79
|
unwatch();
|
|
80
|
+
if (shown) {
|
|
81
|
+
shown = false;
|
|
82
|
+
shownCommands -= 1;
|
|
83
|
+
}
|
|
72
84
|
};
|
|
73
85
|
const settle = (code) => {
|
|
74
86
|
release();
|
package/dist/progress.mjs
CHANGED
|
@@ -39,8 +39,7 @@ function change(progress, issue, update) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
function addHandled(handled, issue, outcome) {
|
|
42
|
-
|
|
43
|
-
return !repeated && (outcome === 'done' || outcome === 'needs-human' || outcome === 'error')
|
|
42
|
+
return outcome === 'done' || outcome === 'needs-human' || outcome === 'error'
|
|
44
43
|
? [...handled, { issue, outcome }]
|
|
45
44
|
: handled;
|
|
46
45
|
}
|
package/dist/serve.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { isNewer } from './protocol.mjs';
|
|
|
11
11
|
import { listQuestions, questionSender, send } from './questions.mjs';
|
|
12
12
|
import { runRepo } from './run.mjs';
|
|
13
13
|
import { packageVersion } from './version.mjs';
|
|
14
|
+
import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
|
|
14
15
|
import { checkSocketPath, workerPaths } from './worker-paths.mjs';
|
|
15
16
|
import { active, endStatus, newRun, requestStop, runControls, runsMessage, startRefusal, stopPoint, } from './worker-run.mjs';
|
|
16
17
|
import { broadcast, closer, fileId, listen, parseMessage, removeOwned, shutdown, } from './worker-server.mjs';
|
|
@@ -134,8 +135,9 @@ export async function startWorker(options) {
|
|
|
134
135
|
idleTimer = setTimeout(closeWhenIdle, options.idleMs ?? IDLE_MS);
|
|
135
136
|
return { closed, close, release: () => removeOwned(owned) };
|
|
136
137
|
}
|
|
137
|
-
export async function serve(root) {
|
|
138
|
-
const paths = workerPaths(root);
|
|
138
|
+
export async function serve(root, logCheckMs = LOG_CHECK_MS) {
|
|
139
|
+
const { logPath, ...paths } = workerPaths(root);
|
|
140
|
+
const stopTrimming = keepLogTrimmed(logPath, logCheckMs);
|
|
139
141
|
const worker = await startWorker({
|
|
140
142
|
root,
|
|
141
143
|
...paths,
|
|
@@ -144,6 +146,7 @@ export async function serve(root) {
|
|
|
144
146
|
questions: listQuestions,
|
|
145
147
|
});
|
|
146
148
|
if (worker === undefined) {
|
|
149
|
+
stopTrimming();
|
|
147
150
|
process.stderr.write('next-issue: another worker is running\n');
|
|
148
151
|
return 1;
|
|
149
152
|
}
|
|
@@ -159,5 +162,6 @@ export async function serve(root) {
|
|
|
159
162
|
process.on('SIGINT', onInterrupt);
|
|
160
163
|
process.stderr.write(`next-issue: worker listening on ${paths.socketPath}\n`);
|
|
161
164
|
await worker.closed;
|
|
165
|
+
stopTrimming();
|
|
162
166
|
return 0;
|
|
163
167
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { closeSync, fstatSync, ftruncateSync, openSync, readSync, writeSync } from 'node:fs';
|
|
2
|
+
import { showingCommands } from './exec.mjs';
|
|
3
|
+
export const LOG_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
4
|
+
export const LOG_KEEP_BYTES = 5 * 1024 * 1024;
|
|
5
|
+
export const LOG_CHECK_MS = 60_000;
|
|
6
|
+
export function trimLog(path) {
|
|
7
|
+
if (showingCommands()) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const file = openSync(path, 'r+');
|
|
12
|
+
try {
|
|
13
|
+
const size = fstatSync(file).size;
|
|
14
|
+
if (size <= LOG_LIMIT_BYTES) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const tail = Buffer.alloc(LOG_KEEP_BYTES);
|
|
18
|
+
const read = readSync(file, tail, 0, LOG_KEEP_BYTES, size - LOG_KEEP_BYTES);
|
|
19
|
+
const kept = tail.subarray(tail.indexOf(10) + 1, read);
|
|
20
|
+
writeSync(file, kept, 0, kept.length, 0);
|
|
21
|
+
ftruncateSync(file, kept.length);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
closeSync(file);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function keepLogTrimmed(path, checkMs) {
|
|
32
|
+
trimLog(path);
|
|
33
|
+
const timer = setInterval(() => trimLog(path), checkMs);
|
|
34
|
+
timer.unref();
|
|
35
|
+
return () => clearInterval(timer);
|
|
36
|
+
}
|
package/dist/worker-paths.mjs
CHANGED