Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(view): a busy --port is refused with its next step [N26]
Corey Olson9a0d00cc7560
diff --git a/src/serve.js b/src/serve.jsindex e27392ef..b421326a 100644--- a/src/serve.js+++ b/src/serve.js@@ -330,12 +330,17 @@ export function serveView({ port = 0, secret = randomBytes(18).toString('base64u}});// Asked for any port, the view tries the one it last served from first, and takes any free one- // when that is busy; a port the person names is used as named.+ // when that is busy; a port the person names is used as named, and a busy one is refused with the+ // way out rather than a stack trace.const asked = port;const last = asked === 0 ? lastPort() : 0;return new Promise((ready, fail) => {const listen = (port) => {- const failed = (error) => (port !== 0 && port === last && error.code === 'EADDRINUSE' ? listen(0) : fail(error));+ const failed = (error) => {+ if (error.code !== 'EADDRINUSE') return fail(error);+ if (port !== 0 && port === last) return listen(0);+ return fail(asked === 0 ? error : new Refused('PORT_BUSY', `port ${asked} is in use: name another with --port, or leave --port out to take any free one`));+ };server.once('error', failed);server.listen(port, LOOPBACK, () => {server.off('error', failed);diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 96c47627..2263e31d 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -918,6 +918,18 @@ test('a closed lifecycle stays closed, across a reload and a restart of the viewawait new Promise((done) => taken.close(done));}});+test('a named port that is busy is refused with the way out, not a stack trace [N26]', async () => {+ const box = machine();+ const held = await new Promise((done) => { const server = createServer(); server.listen(0, '127.0.0.1', () => done(server)); });+ try {+ const port = held.address().port;+ const result = spawnSync(process.execPath, [BIN, 'view', '--no-open', '--port', String(port)], { cwd: box.dir, env: box.env, encoding: 'utf8', timeout: 20000 });+ assert.equal(result.status, 1, `a refusal, not a crash or a hang: ${result.stderr}`);+ assert.equal(result.stderr.trim(), `pullboard: [PORT_BUSY] port ${port} is in use: name another with --port, or leave --port out to take any free one`);+ } finally {+ await new Promise((done) => held.close(done));+ }+});test('ages stay true while the board is quiet [N26]', async () => {const box = machine();const alpha = project(box, 'alpha');