fix(mesh): name the absent teapot in the route-level missing-need error too

assertNeedsSatisfiable is a separate check from topoSort, so it didn't
get the note threaded into finalizeGraph -- a handler-level @needs
against an absent teapot's token read as a typo or a forgotten
export: true, which is worse than the pre-task behavior (the boot used
to throw naming the teapot). Thread missingNote through and soften
"local or mesh" to "local or connected mesh" when it's set, so the
message doesn't claim a search that never happened.

Also tightens two test assertions that only passed because "mesh"
happened to appear inside the unrelated "(local or mesh)" wording, and
removes adopt()'s now-fully-unused attempt parameter in mesh/link.ts
instead of leaving it underscored.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-12 15:40:24 -05:00
1 parent 3b680480ab
commit 4e8aacb6b7
3 files changed
+47 -9

No files matched your search

+31 -3
View File
@@ -102,14 +102,40 @@ describe('mesh boot retry', () => {
try {
// exhausting the budget is no longer fatal by itself (that's the point of this change) —
// the boot still fails here because `who` needs 'auth' and nothing local provides it.
await expect(teacup.fetch(new Request('http://x/api/local/who'))).rejects.toThrow(/mesh/);
// the boot still fails here because `who` needs 'auth' and nothing local provides it. The
// exact message, not a bare /mesh/ match (which would also match this message's own
// "(local or connected mesh)" wording for an unrelated reason).
await expect(teacup.fetch(new Request('http://x/api/local/who'))).rejects.toThrow(
/needs 'auth' but nothing \(local or connected mesh\) provides it[\s\S]*did not connect/i,
);
expect(lines.some((l) => l.includes('starting without it'))).toBe(true);
} finally {
await teacup.close();
}
}, 15_000);
it('names the absent teapot when a route handler needs its token directly', async () => {
// `who` needs 'auth' via `@needs`, not through a `@Step` — this goes through
// `assertNeedsSatisfiable`, a different check than `topoSort`'s, and must carry the same note.
const teacup = createApp({
modules: [TeacupModule],
experimental: true,
mesh: {
teapots: [{ url: 'ws://127.0.0.1:9/x', secret: 's' }],
secret: 's',
bootTimeoutMs: 300,
},
});
try {
await expect(teacup.ready()).rejects.toThrow(
/needs 'auth' but nothing \(local or connected mesh\) provides it[\s\S]*did not connect.*127\.0\.0\.1:9/i,
);
} finally {
await teacup.close();
}
}, 15_000);
it('does not retry a wrong secret — the teapot refused, and it will refuse again', async () => {
const teapot = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: 'good' } });
const server = await teapot.listen(0);
@@ -193,7 +219,9 @@ describe('mesh boot retry', () => {
});
try {
await expect(teacup.fetch(new Request('http://x/api/local/who'))).rejects.toThrow(/mesh/);
await expect(teacup.fetch(new Request('http://x/api/local/who'))).rejects.toThrow(
/needs 'auth' but nothing \(local or connected mesh\) provides it[\s\S]*did not connect/i,
);
expect(lines.filter((l) => l.includes('of boot budget left'))).toEqual([]);
} finally {
await teacup.close();