commit 4832c7072e653cf0e260f57f3ce2ebd4854f73f9
parent e95d22625ee92b637dcb27bcb5a51bf29a55e772
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 10 Oct 2026 15:57:02 -0400
e2e: a worker slot's ports skip the browsers' bad ports
`next start` refuses 5060 ("reserved for sip"), and worktree #20's slot 1 sat
there. Slot ports now walk up from x060 past the Fetch standard's bad ports
(5060, 5061, 6000, 6665–6669, …), still inside the worktree's block.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/editor/e2e/servers.ts b/editor/e2e/servers.ts
@@ -104,11 +104,18 @@ export function resolveWorkers(
export type SlotPorts = { editor: number; export: number; ollama: number };
+// The Fetch standard's "bad ports" at or above 3000: a browser refuses them,
+// and so does `next start` ("Bad port: "5060" is reserved for sip"). Worktree
+// #20's block (50xx) has two of them where slot 1 would sit.
+export const UNSAFE_PORTS: ReadonlySet<number> = new Set([
+ 3659, 4045, 4190, 5060, 5061, 6000, 6566, 6665, 6666, 6667, 6668, 6669, 6679, 6697, 10080,
+]);
+
/**
* A slot's three ports. Slot 0 is the suite's own (common/lib/ports.mjs, with
- * the worktree's offset). Slot n takes three from the unused top of the
- * worktree's block — `x060 + 3(n−1)` … — so no other worktree's ports, and no
- * other suite's, are ever touched.
+ * the worktree's offset). Slot n takes the next three from the unused top of
+ * the worktree's block — from `x060` up, skipping a bad port — so no other
+ * worktree's ports, and no other suite's, are ever touched.
*/
export function slotPorts(slot: number, env: Env = process.env): SlotPorts {
if (slot <= 0) {
@@ -119,8 +126,12 @@ export function slotPorts(slot: number, env: Env = process.env): SlotPorts {
};
}
const offset = portFor("PORT", env) - PORT_BASES.PORT;
- const base = PORT_BASES.PORT + 49 + offset + 3 * (slot - 1);
- return { editor: base, export: base + 1, ollama: base + 2 };
+ const usable: number[] = [];
+ for (let p = PORT_BASES.PORT + 49 + offset; usable.length < 3 * slot; p++) {
+ if (!UNSAFE_PORTS.has(p)) usable.push(p);
+ }
+ const [editor, exportPort, ollama] = usable.slice(3 * (slot - 1));
+ return { editor, export: exportPort, ollama };
}
// ------------------------------------------------------------------ servers
diff --git a/editor/e2e/servers.unit.ts b/editor/e2e/servers.unit.ts
@@ -31,9 +31,18 @@ test("slotPorts: slot 0 is the suite's own; slot n takes three from the top of t
// A worktree at offset 2000 (PORT=5011, the injector's): its own block.
const wt = { PORT: "5011", EXPORT_PORT: "5010", OLLAMA_STUB_PORT: "13435" };
assert.deepEqual(slotPorts(0, wt), { editor: 5011, export: 5010, ollama: 13435 });
- assert.deepEqual(slotPorts(3, wt), { editor: 5066, export: 5067, ollama: 5068 });
- // Eight slots stay inside the block of a hundred.
- assert.ok(slotPorts(7, {}).ollama < 3100);
+ // 5060 and 5061 are bad ports (SIP): `next start` refuses them.
+ assert.deepEqual(slotPorts(1, wt), { editor: 5062, export: 5063, ollama: 5064 });
+ assert.deepEqual(slotPorts(3, wt), { editor: 5068, export: 5069, ollama: 5070 });
+ // Eight slots stay inside the block of a hundred, past every bad port.
+ assert.ok(slotPorts(8, {}).ollama < 3100);
+ const wt66 = { PORT: "9611" }; // worktree #66: 6665–6669 are bad
+ for (let s = 1; s <= 8; s++) {
+ const p = slotPorts(s, { PORT: "6611" });
+ assert.ok(![p.editor, p.export, p.ollama].some((n) => n >= 6665 && n <= 6669), `slot ${s}`);
+ assert.ok(p.ollama < 6700, `slot ${s} left the block`);
+ }
+ assert.ok(slotPorts(1, wt66).editor === 9660);
});
test("slotServers: slot 0 is the webServer of before; slot n is its own data root, ports and dist dirs", () => {