Skip to content

Commit 2bfa70d

Browse files
committed
Keep dry-run discovery resilient
Report inbox discovery failures per recipient during dry runs so one bad actor lookup does not hide the rest of the benchmark plan. #795 (comment) Assisted-by: Codex:gpt-5.5
1 parent a7149a9 commit 2bfa70d

2 files changed

Lines changed: 61 additions & 6 deletions

File tree

packages/cli/src/bench/action.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,45 @@ test("runBench - dry run prints a plan and sends nothing", async () => {
169169
}
170170
});
171171

172+
test("runBench - dry run reports inbox discovery failures and continues", async () => {
173+
const target = await spawnBenchmarkTarget();
174+
try {
175+
const file = await writeSuite(`version: 1
176+
target: ${target.url.href}
177+
scenarios:
178+
- name: inbox-shared
179+
type: inbox
180+
recipient:
181+
- "${new URL("/users/missing", target.url).href}"
182+
- "${new URL("/users/alice", target.url).href}"
183+
inbox: shared
184+
load: { concurrency: 2 }
185+
duration: 250ms
186+
`);
187+
let code = -1;
188+
let output = "";
189+
await runBench(command({ scenario: file, dryRun: true }), {
190+
exit: (c) => {
191+
code = c;
192+
},
193+
writeOutput: (c) => {
194+
output = c;
195+
return Promise.resolve();
196+
},
197+
log: () => {},
198+
});
199+
assert.strictEqual(code, 0);
200+
assert.match(output, /\/users\/missing/);
201+
assert.match(output, /discovery failed/);
202+
assert.match(output, /\/users\/alice/);
203+
assert.match(output, /\/inbox/);
204+
assert.match(output, /No benchmark load was sent/);
205+
assert.ok(!target.requests().some((r) => r.method === "POST"));
206+
} finally {
207+
await target.close();
208+
}
209+
});
210+
172211
test("runBench - unsafe override requires an explicit CLI target", async () => {
173212
const file = await writeSuite(`version: 1
174213
target: https://example.com

packages/cli/src/bench/action.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import process from "node:process";
44
import { getContextLoader, getDocumentLoader } from "../docloader.ts";
55
import { buildFleet } from "./actor/fleet.ts";
66
import type { BenchCommand } from "./command.ts";
7-
import { discoverInbox, selectInbox } from "./discovery/discover.ts";
7+
import {
8+
type DiscoveredInbox,
9+
discoverInbox,
10+
selectInbox,
11+
} from "./discovery/discover.ts";
812
import {
913
buildReport,
1014
buildScenarioResult,
@@ -398,11 +402,19 @@ async function describeInboxDiscoveryPlan(
398402
): Promise<string[]> {
399403
const lines: string[] = [];
400404
for (const recipient of scenario.recipients) {
401-
const discovered = await discoverInbox(recipient, {
402-
documentLoader: context.documentLoader,
403-
contextLoader: context.contextLoader,
404-
allowPrivateAddress: context.allowPrivateAddress,
405-
});
405+
let discovered: DiscoveredInbox;
406+
try {
407+
discovered = await discoverInbox(recipient, {
408+
documentLoader: context.documentLoader,
409+
contextLoader: context.contextLoader,
410+
allowPrivateAddress: context.allowPrivateAddress,
411+
});
412+
} catch (error) {
413+
lines.push(
414+
` recipient ${recipient}: discovery failed (${describeError(error)})`,
415+
);
416+
continue;
417+
}
406418
const inbox = selectInbox(discovered, scenario.inbox);
407419
lines.push(
408420
` recipient ${recipient}: actor ${discovered.actorUri.href}, ` +
@@ -419,6 +431,10 @@ async function describeInboxDiscoveryPlan(
419431
return lines;
420432
}
421433

434+
function describeError(error: unknown): string {
435+
return error instanceof Error ? error.message : String(error);
436+
}
437+
422438
function describeWebFingerPlan(
423439
scenario: ResolvedScenario,
424440
target: URL,

0 commit comments

Comments
 (0)