fix(discord): the connector's STOP refusal names the journal by label (#1873)
Re-check 3 found connector.start() still quoted the journal directory in its STOP refusal, and the CLI passes a DiscordError through unchanged. It now uses journalLabel like the CLI and journal refusals. The connector test asserts the path is absent: 22/1 on the old source, 23/0 after.
This commit was merged in pull request #1933.
This commit is contained in:
1 parent
63e2a574af
commit
ce4fe048bb
2 files changed
+3
-3
No files matched your search
@@ -35,7 +35,7 @@ import { reloadDiff } from "./binding.mjs";
|
|||||||
import { envelope, splitReply } from "./context.mjs";
|
import { envelope, splitReply } from "./context.mjs";
|
||||||
import {
|
import {
|
||||||
ensureJournal, appendInbox, readInboxIds, appendOutbox, unresolvedOutbox, appendDrop,
|
ensureJournal, appendInbox, readInboxIds, appendOutbox, unresolvedOutbox, appendDrop,
|
||||||
writeTurn, appendAdmission, countAdmissionsOn, appendNotice, noticeOn, utcDate, stopRequested,
|
writeTurn, appendAdmission, countAdmissionsOn, appendNotice, noticeOn, utcDate, stopRequested, journalLabel,
|
||||||
} from "./journal.mjs";
|
} from "./journal.mjs";
|
||||||
import { RestOutcome } from "./rest.mjs";
|
import { RestOutcome } from "./rest.mjs";
|
||||||
import { DiscordError } from "./errors.mjs";
|
import { DiscordError } from "./errors.mjs";
|
||||||
@@ -596,7 +596,7 @@ ${status === "not-posted" ? APPROVAL_LINES.pressAgain : APPROVAL_LINES.failed}`;
|
|||||||
async start() {
|
async start() {
|
||||||
processing();
|
processing();
|
||||||
if (state.started) throw new DiscordError("connector already started", 1);
|
if (state.started) throw new DiscordError("connector already started", 1);
|
||||||
if (stopRequested(journalDir)) throw new DiscordError(`STOP is present in ${journalDir}; remove it to run`, 1);
|
if (stopRequested(journalDir)) throw new DiscordError(`STOP is present in ${journalLabel(journalDir)}; remove it to run`, 1);
|
||||||
const reconciled = await reconcile();
|
const reconciled = await reconcile();
|
||||||
const approvals = await reconcileApprovals();
|
const approvals = await reconcileApprovals();
|
||||||
processing();
|
processing();
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ test("restart: an inbox with three ids and a replay of the same three produces z
|
|||||||
test("stop: STOP present refuses start; STOP written while running refuses new turns and the current one finishes", async () => {
|
test("stop: STOP present refuses start; STOP written while running refuses new turns and the current one finishes", async () => {
|
||||||
const { journalDir, rest, engine, connector } = setup({ replies: [{ text: "done", delayMs: 30 }] });
|
const { journalDir, rest, engine, connector } = setup({ replies: [{ text: "done", delayMs: 30 }] });
|
||||||
requestStop(journalDir, "test");
|
requestStop(journalDir, "test");
|
||||||
await assert.rejects(connector.start(), /STOP is present/);
|
await assert.rejects(connector.start(), (err) => /STOP is present/.test(err.message) && !err.message.includes(journalDir));
|
||||||
assert.equal(engine.started, false);
|
assert.equal(engine.started, false);
|
||||||
writeFileSync(join(journalDir, "STOP"), ""); // still present; clear it
|
writeFileSync(join(journalDir, "STOP"), ""); // still present; clear it
|
||||||
const { unlinkSync } = await import("node:fs");
|
const { unlinkSync } = await import("node:fs");
|
||||||
|
|||||||
Reference in new issue
Block a user