feat(mesh)!: reserve /__mesh__/control on every adapter (CARD-21, #126)

The Node upgrade listener only intercepted /__mesh__/control when a mesh
control channel was configured; otherwise a user @Ws route there was
served. app.upgrade (Deno, Bun, edge) always checked the path first and
closed 1008. The same app therefore worked on Node and was refused
everywhere else.

D17 makes the path reserved in every app, mesh or not:

- createApp fails when a @Ws, @Stream or HTTP route claims the path,
  naming the declaration. A literal pattern is checked by equality, a
  parameterised one (/__mesh__/:x, /__mesh__/:rest*) by matching the
  reserved path against it. Patterns whose first segment is not the
  literal __mesh__ (/:org/:repo, /:rest*) still boot: the adapters
  answer the path before route matching, so those routes never see it.
- A route exported by a teapot is checked during the teacup splice.
- The Node listener, with no control channel, accepts the upgrade and
  closes 1008 with the reason app.upgrade gives. The reason is now one
  shared constant.

The check lives in src/http/reserved-paths.ts so CARD-17 can add
/__live__ and /__ready__ to the same list.

BREAKING CHANGE: an app that declares a route at /__mesh__/control, or a
pattern under /__mesh__/ that matches it, now fails createApp.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-10-23 00:53:55 -05:00
1 parent 444910b6f0
commit 2c00cc3407
10 files changed
+478 -7

No files matched your search

+40
View File
@@ -181,3 +181,43 @@ Deno.test('serveDeno: ws message size default is 1 MiB', async () => {
await server.shutdown();
}
});
// CARD-21 (D17): the reserved mesh path is refused the way the Node listener refuses it, and a route
// that claims it fails createApp here too.
Deno.test('serveDeno: /__mesh__/control without a control channel closes 1008; a route there fails createApp', async () => {
@Route('/')
class Claims {
@Ws('/__mesh__/control')
control() {
return (async function* () {})();
}
}
@Module({ mountpoint: '/', controllers: [Claims] })
class ClaimsModule {}
let message = '';
try {
createApp({ modules: [ClaimsModule] });
} catch (error) {
message = (error as Error).message;
}
assertEquals(message.startsWith('route @Ws /__mesh__/control at Claims.control uses the reserved path'), true);
const app = createApp({ modules: [M] });
let port = 0;
const server = await serveDeno(app, {
port: 0,
onListen: (addr) => {
port = addr.port;
},
});
await new Promise((resolve) => setTimeout(resolve, 50));
try {
assertEquals((await exchange(port, '/__mesh__/control', [])).close, {
code: 1008,
reason: 'mesh control channel not enabled: this app exports nothing, or has no mesh.secret',
});
} finally {
await server.shutdown();
}
});