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