fix(mesh): name the teapot in the boot log a later 404 points back to

A route the absent teapot would have exported 404s, and that is the right
status: nothing was ever registered for a manifest that never arrived, so
there is no path to serve. But a bare 404 is indistinguishable from a typo
in the path, and the boot log is the only place the two are told apart.

It could not tell them apart either. The give-up warning relied on the
error's own message to identify the teapot, which holds for a refusal --
`mesh handshake failed: <url>` -- but not for an unreachable one, where the
error is a socket error that may carry no url at all. So the url is passed
in now, and every line of the boot-connect story names it: the retries, the
refusal, and the give-up. The give-up line also says no manifest was ever
exchanged, which is the fact that explains the 404.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-12 15:40:26 -05:00
1 parent 6e050197b6
commit 249fc00f80
2 files changed
+44 -7

No files matched your search

+9 -7
View File
@@ -775,6 +775,7 @@ async function connectUntilDeadline(
mesh: MeshConfig,
bus: Bus,
logger: Logger,
url: string,
attempt: () => Promise<Link>,
): Promise<Link | undefined> {
const budgetMs = mesh.bootTimeoutMs ?? mesh.timeoutMs ?? 30_000;
@@ -793,7 +794,7 @@ async function connectUntilDeadline(
// thirty seconds. Retrying a wrong secret only spends the deploy's patience to reach the
// identical error, so it fails now.
if (isPermanentRefusal(error)) {
logger.error(`mesh: the teapot refused this peer, which retrying cannot fix — ${(error as Error).message}`);
logger.error(`mesh: teapot ${url} refused this peer, which retrying cannot fix — ${(error as Error).message}`);
throw error;
}
@@ -804,17 +805,18 @@ async function connectUntilDeadline(
// at all — its routes 404 and a local `needs` on its tokens still fails in finalize().
if (remaining <= 0) {
logger.warn(
`mesh: teapot unreachable after ${attempts} attempt(s) over ${budgetMs}ms ` +
`(${(error as Error).message}) — starting without it. It sent no manifest, so none of ` +
`its steps or routes are in this graph: its routes 404, and the boot still fails if ` +
`anything local needs one of its tokens.`,
`mesh: teapot ${url} unreachable after ${attempts} attempt(s) over ${budgetMs}ms ` +
`(${(error as Error).message}) — starting without it. No manifest was ever exchanged, ` +
`so none of its steps or routes are in this graph: its routes 404 like any path that ` +
`was never registered, and the boot still fails if anything local needs one of its ` +
`tokens. This line is what a later 404 on one of its routes points back to.`,
);
return undefined;
}
bus.emit('mesh:boot:retry', { name: `attempt ${attempts}`, error });
logger.warn(
`mesh: teapot unreachable (${(error as Error).message}) — retrying, ${remaining}ms of boot budget left`,
`mesh: teapot ${url} unreachable (${(error as Error).message}) — retrying, ${remaining}ms of boot budget left`,
);
await new Promise((resolve) => setTimeout(resolve, Math.min(delay, Math.max(0, remaining))));
delay = Math.min(delay * 2, 5_000);
@@ -857,7 +859,7 @@ async function spliceRemoteScopes(
try {
for (const teapot of mesh.teapots ?? []) {
warnIfCleartext(teapot.url, logger);
const link = await connectUntilDeadline(mesh, bus, logger, () =>
const link = await connectUntilDeadline(mesh, bus, logger, teapot.url, () =>
connectLink({
url: teapot.url,
secret: teapot.secret,
+35
View File
@@ -191,6 +191,41 @@ describe('mesh boot retry', () => {
}
}, 15_000);
it('names the teapot in the log a later 404 points back to', async () => {
// A route the absent teapot would have exported 404s, because nothing was ever registered for a
// manifest that never arrived. That is the right status — you cannot serve what was never
// declared — but a bare 404 is indistinguishable from a typo in the path. The boot log is the
// only place the two are told apart, so it has to name *which* teapot and say that no manifest
// was exchanged. The unreachable error itself is a socket error and does not reliably carry
// the url, so the url is passed in rather than scraped out of the message.
const { lines, logger } = collect();
const teacup = createApp({
modules: [LocalOnlyModule],
experimental: true,
logger,
mesh: {
teapots: [{ url: 'ws://127.0.0.1:9/x', secret: 's' }],
secret: 's',
bootTimeoutMs: 300,
},
});
try {
await teacup.ready();
const gaveUp = lines.find((line) => line.includes('starting without it'));
expect(gaveUp).toBeDefined();
expect(gaveUp).toContain('ws://127.0.0.1:9/x');
expect(gaveUp).toMatch(/no manifest was ever exchanged/i);
expect(gaveUp).toMatch(/404/);
// and the retry lines on the way there name it too, so a deploy tailing logs sees which one
expect(lines.some((line) => /retrying/.test(line) && line.includes('ws://127.0.0.1:9/x'))).toBe(true);
} finally {
await teacup.close();
}
}, 15_000);
it('still fails the boot when a local step needs a token the absent teapot owned', async () => {
const teacup = createApp({
modules: [NeedsAuthModule], // a step with needs: ['auth']