next-issue 6.6.4 → 6.6.5
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 +2 -1
- package/dist/lock.mjs +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -549,7 +549,8 @@ affect another. The worker:
|
|
|
549
549
|
lock is stale, and is taken over, when no process has that id or the process
|
|
550
550
|
with that id started at another time, for example because the system gave
|
|
551
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
|
|
552
|
+
A lock without a start time, from an older version, is stale too. A worker
|
|
553
|
+
that cannot read its own start time exits with an error and takes no lock;
|
|
553
554
|
- refuses a `start`, `stop` or `questions` message whose `root` is not
|
|
554
555
|
the exact path of its repository with an `error` message, and starts or
|
|
555
556
|
stops nothing;
|
package/dist/lock.mjs
CHANGED
|
@@ -42,11 +42,15 @@ export async function stopWorker(lockPath) {
|
|
|
42
42
|
}
|
|
43
43
|
return pid;
|
|
44
44
|
}
|
|
45
|
-
export async function lock(path, waitMs) {
|
|
45
|
+
export async function lock(path, waitMs, readStart = processStart) {
|
|
46
|
+
const started = await readStart(process.pid);
|
|
47
|
+
if (started === undefined) {
|
|
48
|
+
throw new Error('next-issue: cannot read the start time of the worker process');
|
|
49
|
+
}
|
|
46
50
|
const deadline = Date.now() + waitMs;
|
|
47
51
|
for (;;) {
|
|
48
52
|
try {
|
|
49
|
-
await writeFile(path, `${process.pid} ${
|
|
53
|
+
await writeFile(path, `${process.pid} ${started}\n`, {
|
|
50
54
|
flag: 'wx',
|
|
51
55
|
mode: 0o600,
|
|
52
56
|
});
|