@orkestrel/server 0.0.31 → 0.0.32
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.
package/dist/src/server/index.js
CHANGED
|
@@ -2133,6 +2133,7 @@ var Server = class {
|
|
|
2133
2133
|
#options;
|
|
2134
2134
|
#sockets;
|
|
2135
2135
|
#http;
|
|
2136
|
+
#binding;
|
|
2136
2137
|
#wakeup = createAbort();
|
|
2137
2138
|
#status = "idle";
|
|
2138
2139
|
#port;
|
|
@@ -2282,12 +2283,13 @@ var Server = class {
|
|
|
2282
2283
|
this.#emitter.destroy();
|
|
2283
2284
|
return;
|
|
2284
2285
|
}
|
|
2286
|
+
this.#status = "stopped";
|
|
2287
|
+
this.#binding?.abort(new ServerError("STATUS", "server destroyed while starting", { status: "starting" }));
|
|
2285
2288
|
for (const exchange of this.#requests) exchange.abort();
|
|
2286
2289
|
const server = this.#http;
|
|
2287
2290
|
if (server !== void 0) await this.#close(server, true);
|
|
2288
2291
|
this.#http = void 0;
|
|
2289
2292
|
this.#port = void 0;
|
|
2290
|
-
this.#status = "stopped";
|
|
2291
2293
|
this.#emitter.destroy();
|
|
2292
2294
|
}
|
|
2293
2295
|
async #stopGracefully() {
|
|
@@ -2442,6 +2444,7 @@ var Server = class {
|
|
|
2442
2444
|
const deadline = this.#startup === void 0 ? void 0 : createTimeout({ ms: this.#startup });
|
|
2443
2445
|
const startup = deadline === void 0 ? signal : linkSignal(deadline.signal, signal);
|
|
2444
2446
|
const binding = createAbort();
|
|
2447
|
+
this.#binding = binding;
|
|
2445
2448
|
const relay = startup === void 0 ? void 0 : addAbortListener(startup, () => binding.abort(startup.reason));
|
|
2446
2449
|
const operation = new ServerBinding();
|
|
2447
2450
|
try {
|
|
@@ -2457,22 +2460,28 @@ var Server = class {
|
|
|
2457
2460
|
signal: binding.signal
|
|
2458
2461
|
});
|
|
2459
2462
|
await listening;
|
|
2463
|
+
if (this.#status !== "starting") throw new ServerError("STATUS", "server destroyed while starting", { status: this.#status });
|
|
2460
2464
|
operation.record(server.address());
|
|
2461
2465
|
} catch (error) {
|
|
2466
|
+
const destroyed = this.#status === "stopped";
|
|
2462
2467
|
const expired = deadline?.expired === true;
|
|
2463
2468
|
const cancelled = startup?.aborted === true;
|
|
2464
2469
|
server.on("error", () => void 0);
|
|
2465
2470
|
binding.abort(error);
|
|
2466
2471
|
const listening = operation.pending;
|
|
2467
2472
|
if (listening !== void 0) await listening.catch(() => void 0);
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2473
|
+
if (!destroyed) {
|
|
2474
|
+
await this.#close(server, true);
|
|
2475
|
+
this.#http = void 0;
|
|
2476
|
+
this.#port = void 0;
|
|
2477
|
+
this.#status = "idle";
|
|
2478
|
+
}
|
|
2479
|
+
if (destroyed) throw new ServerError("STATUS", "server destroyed while starting", { status: "starting" });
|
|
2472
2480
|
if (expired && deadline !== void 0) throw new DOMException(`Server startup exceeded ${deadline.ms} milliseconds`, "TimeoutError");
|
|
2473
2481
|
if (cancelled && startup !== void 0) throw startup.reason;
|
|
2474
2482
|
throw error;
|
|
2475
2483
|
} finally {
|
|
2484
|
+
if (this.#binding === binding) this.#binding = void 0;
|
|
2476
2485
|
relay?.[Symbol.dispose]();
|
|
2477
2486
|
deadline?.clear();
|
|
2478
2487
|
}
|