next-issue 6.6.2 → 6.6.4
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 +9 -6
- package/dist/gate.mjs +15 -2
- package/dist/lock.mjs +24 -8
- package/dist/pipeline.mjs +2 -1
- package/dist/run.mjs +1 -1
- package/dist/watch.mjs +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -544,9 +544,12 @@ affect another. The worker:
|
|
|
544
544
|
repository. Only your user can open the file. It works on macOS and Linux.
|
|
545
545
|
When the path of the socket file is too long for the system, about 103
|
|
546
546
|
bytes on macOS and 107 on Linux, it exits with an error that says so;
|
|
547
|
-
- holds `.next-issue/worker.lock` in the repository, with its process id
|
|
548
|
-
only one worker runs per repository. A
|
|
549
|
-
is taken over
|
|
547
|
+
- holds `.next-issue/worker.lock` in the repository, with its process id and
|
|
548
|
+
the start time of that process, so only one worker runs per repository. A
|
|
549
|
+
lock is stale, and is taken over, when no process has that id or the process
|
|
550
|
+
with that id started at another time, for example because the system gave
|
|
551
|
+
the id of a worker that was killed or lost in a reboot to another process.
|
|
552
|
+
A lock without a start time, from an older version, is stale too;
|
|
550
553
|
- refuses a `start`, `stop` or `questions` message whose `root` is not
|
|
551
554
|
the exact path of its repository with an `error` message, and starts or
|
|
552
555
|
stops nothing;
|
|
@@ -595,9 +598,9 @@ affect another. The worker:
|
|
|
595
598
|
|
|
596
599
|
Stop the worker of a repository with `next-issue stop` in that repository.
|
|
597
600
|
Workers of other repositories carry on. This sends `SIGTERM` to the process in
|
|
598
|
-
the lock file, so the worker stops at once and a
|
|
599
|
-
its saved state next time. When no worker is
|
|
600
|
-
exits with 0.
|
|
601
|
+
the lock file when the lock is not stale, so the worker stops at once and a
|
|
602
|
+
run that is going resumes from its saved state next time. When no worker is
|
|
603
|
+
running, the command says so and exits with 0.
|
|
601
604
|
|
|
602
605
|
Versions before one worker per repository ran one worker for the machine,
|
|
603
606
|
with `next-issue.sock`, `next-issue.lock` and `next-issue.roots.json` in
|
package/dist/gate.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { budgetUse } from './budget.mjs';
|
|
2
2
|
import { checkWaiting } from './check-poll.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { runStopped } from './children.mjs';
|
|
4
|
+
import { asError, message } from './errors.mjs';
|
|
4
5
|
import { escalateCheckFix, fixRound } from './fix.mjs';
|
|
5
6
|
import { escalateAndFinish } from './handover.mjs';
|
|
6
7
|
import { GATE_FIXED, GATE_PASSED } from './job.mjs';
|
|
@@ -54,7 +55,19 @@ async function failedChecksFix(job, sha) {
|
|
|
54
55
|
await writeState(repo, state);
|
|
55
56
|
const logs = await ports.failedBaseLogs(repo, sha, config.logMaxChars);
|
|
56
57
|
log.event('main-checks.logs', { chars: logs.length });
|
|
57
|
-
|
|
58
|
+
let fix;
|
|
59
|
+
try {
|
|
60
|
+
fix = await fixRound(job, `The checks on ${base} failed after the change landed there.`, logs, [], 'checks');
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (runStopped()) {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
const reverted = await revert(job);
|
|
67
|
+
const detail = message(error);
|
|
68
|
+
const stop = detail.endsWith('.') ? '' : '.';
|
|
69
|
+
return escalateAndFinish(job, `The fixer for the failed checks on ${base} failed: ${detail}${stop}${reverted}`, 'fixer error');
|
|
70
|
+
}
|
|
58
71
|
if (!fix.committed) {
|
|
59
72
|
const reverted = await revert(job);
|
|
60
73
|
return escalateCheckFix(job, fix.unrelated, `checks on ${base}`, reverted);
|
package/dist/lock.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
1
2
|
import { rm, writeFile } from 'node:fs/promises';
|
|
2
3
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
3
5
|
import { hasCode } from './errors.mjs';
|
|
4
6
|
import { readTextOrEmpty } from './files.mjs';
|
|
5
7
|
const LOCK_POLL_MS = 100;
|
|
@@ -9,18 +11,29 @@ export function oneAtATime(root, work) {
|
|
|
9
11
|
worktreeQueues.set(root, result.catch(() => undefined));
|
|
10
12
|
return result;
|
|
11
13
|
}
|
|
12
|
-
function
|
|
14
|
+
export async function processStart(pid) {
|
|
15
|
+
const stat = await readTextOrEmpty(`/proc/${pid}/stat`);
|
|
16
|
+
if (stat !== '') {
|
|
17
|
+
return stat.slice(stat.lastIndexOf(')') + 2).split(' ')[19];
|
|
18
|
+
}
|
|
13
19
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
const { stdout } = await promisify(execFile)('ps', ['-o', 'lstart=', '-p', String(pid)], {
|
|
21
|
+
env: { ...process.env, LC_ALL: 'C' },
|
|
22
|
+
});
|
|
23
|
+
return stdout.trim() || undefined;
|
|
16
24
|
}
|
|
17
|
-
catch
|
|
18
|
-
return
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
async function holder(lockPath) {
|
|
22
|
-
const
|
|
23
|
-
|
|
30
|
+
const [first = '', ...rest] = (await readTextOrEmpty(lockPath)).trim().split(' ');
|
|
31
|
+
const pid = Number(first);
|
|
32
|
+
const started = rest.join(' ');
|
|
33
|
+
if (!(pid > 0) || started === '') {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return (await processStart(pid)) === started ? pid : undefined;
|
|
24
37
|
}
|
|
25
38
|
export async function stopWorker(lockPath) {
|
|
26
39
|
const pid = await holder(lockPath);
|
|
@@ -33,7 +46,10 @@ export async function lock(path, waitMs) {
|
|
|
33
46
|
const deadline = Date.now() + waitMs;
|
|
34
47
|
for (;;) {
|
|
35
48
|
try {
|
|
36
|
-
await writeFile(path, `${process.pid}\n`, {
|
|
49
|
+
await writeFile(path, `${process.pid} ${await processStart(process.pid)}\n`, {
|
|
50
|
+
flag: 'wx',
|
|
51
|
+
mode: 0o600,
|
|
52
|
+
});
|
|
37
53
|
return true;
|
|
38
54
|
}
|
|
39
55
|
catch (error) {
|
package/dist/pipeline.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { reviewRound } from './review.mjs';
|
|
|
8
8
|
import { skipReport, unclaimedError } from './skip.mjs';
|
|
9
9
|
import { newState, readState, resetState } from './state.mjs';
|
|
10
10
|
import { setUp } from './worktree-setup.mjs';
|
|
11
|
-
export async function processIssue(context, issue) {
|
|
11
|
+
export async function processIssue(context, issue, claimed = () => undefined) {
|
|
12
12
|
const { repo } = context;
|
|
13
13
|
const started = Date.now();
|
|
14
14
|
const log = context.recorder.scope({ issue: issue.number });
|
|
@@ -23,6 +23,7 @@ export async function processIssue(context, issue) {
|
|
|
23
23
|
if (skip !== undefined) {
|
|
24
24
|
return skip;
|
|
25
25
|
}
|
|
26
|
+
claimed();
|
|
26
27
|
log.event('issue.start', { title: issue.title, createdAt: issue.createdAt }, 'quiet');
|
|
27
28
|
const state = startState(context, issue, saved);
|
|
28
29
|
let report;
|
package/dist/run.mjs
CHANGED
|
@@ -40,7 +40,7 @@ async function handle(args, config, repo, recorder, controls) {
|
|
|
40
40
|
const context = await startRun(args, config, repo, recorder, interrupts);
|
|
41
41
|
const loop = {
|
|
42
42
|
issues: () => pendingIssues(context),
|
|
43
|
-
process: (issue) => processIssue(context, issue),
|
|
43
|
+
process: (issue, claimed) => processIssue(context, issue, claimed),
|
|
44
44
|
stop: interrupts.afterIssue,
|
|
45
45
|
concurrency: config.concurrency,
|
|
46
46
|
};
|
package/dist/watch.mjs
CHANGED
|
@@ -12,9 +12,8 @@ export async function watchIssues(args, watch) {
|
|
|
12
12
|
...watch,
|
|
13
13
|
process: async (issue) => {
|
|
14
14
|
running.add(issue.number);
|
|
15
|
-
claims.ring();
|
|
16
15
|
try {
|
|
17
|
-
return await watch.process(issue);
|
|
16
|
+
return await watch.process(issue, claims.ring);
|
|
18
17
|
}
|
|
19
18
|
finally {
|
|
20
19
|
running.delete(issue.number);
|