@rogatio/cli 5.7.2 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/node/index.js +21 -26
  2. package/package.json +1 -1
@@ -23116,7 +23116,6 @@ function redactKey(key) {
23116
23116
  import { resolve as resolve4 } from "node:path";
23117
23117
 
23118
23118
  // packages/cli/src/server/http.ts
23119
- import { randomInt } from "node:crypto";
23120
23119
  import {
23121
23120
  createServer as createHttpServer
23122
23121
  } from "node:http";
@@ -23142,6 +23141,16 @@ function createServer2(handler, options = {}) {
23142
23141
  });
23143
23142
  });
23144
23143
  }
23144
+ function boundPort() {
23145
+ const address = server.address();
23146
+ if (address === null || typeof address === "string") {
23147
+ throw new HttpServerError(
23148
+ "listen-failed",
23149
+ "Failed to resolve bound port after listen"
23150
+ );
23151
+ }
23152
+ return address.port;
23153
+ }
23145
23154
  return {
23146
23155
  get port() {
23147
23156
  if (port === null)
@@ -23164,32 +23173,18 @@ function createServer2(handler, options = {}) {
23164
23173
  );
23165
23174
  }
23166
23175
  }
23167
- const maxRetries = 8;
23168
- let lastError = null;
23169
- for (let attempt = 0; attempt < maxRetries; attempt++) {
23170
- const candidatePort = randomInt(1024, 65535);
23171
- try {
23172
- await listenOn(candidatePort);
23173
- port = candidatePort;
23174
- started = true;
23175
- return;
23176
- } catch (e) {
23177
- lastError = e;
23178
- const code = e.code;
23179
- if (code !== "EADDRINUSE" && code !== "EACCES") {
23180
- throw new HttpServerError(
23181
- "listen-failed",
23182
- `Failed to start server: ${e}`,
23183
- e
23184
- );
23185
- }
23186
- }
23176
+ try {
23177
+ await listenOn(0);
23178
+ port = boundPort();
23179
+ started = true;
23180
+ } catch (e) {
23181
+ if (e instanceof HttpServerError) throw e;
23182
+ throw new HttpServerError(
23183
+ "listen-failed",
23184
+ `Failed to start server: ${e}`,
23185
+ e
23186
+ );
23187
23187
  }
23188
- throw new HttpServerError(
23189
- "port-exhausted",
23190
- `Failed to bind to port after ${maxRetries} attempts`,
23191
- lastError ?? void 0
23192
- );
23193
23188
  },
23194
23189
  async stop() {
23195
23190
  if (!started) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogatio/cli",
3
- "version": "5.7.2",
3
+ "version": "5.8.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local-first browser request and response rules — editor host, file verification, test runner, and runtime dispatch.",