srvx 0.10.0 → 0.10.1
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.
|
@@ -31,16 +31,26 @@ const gracefulShutdownPlugin = (server) => {
|
|
|
31
31
|
const gracefulShutdown = config === true || !config?.gracefulTimeout ? Number.parseInt(process.env.SERVER_SHUTDOWN_TIMEOUT || "") || 3 : config.gracefulTimeout;
|
|
32
32
|
const forceShutdown = config === true || !config?.forceTimeout ? Number.parseInt(process.env.SERVER_FORCE_SHUTDOWN_TIMEOUT || "") || 5 : config.forceTimeout;
|
|
33
33
|
let isShuttingDown = false;
|
|
34
|
+
let forceClose;
|
|
34
35
|
const shutdown = async () => {
|
|
35
|
-
if (isShuttingDown)
|
|
36
|
+
if (isShuttingDown) {
|
|
37
|
+
forceClose?.();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
36
40
|
isShuttingDown = true;
|
|
37
41
|
const w = process.stderr.write.bind(process.stderr);
|
|
38
|
-
w(gray(`\nShutting down server in ${gracefulShutdown}s
|
|
42
|
+
w(gray(`\nShutting down server in ${gracefulShutdown}s... (press Ctrl+C again to force close)`));
|
|
39
43
|
let timeout;
|
|
40
44
|
await Promise.race([server.close().finally(() => {
|
|
41
45
|
clearTimeout(timeout);
|
|
42
46
|
w(gray(" Server closed.\n"));
|
|
43
47
|
}), new Promise((resolve) => {
|
|
48
|
+
forceClose = () => {
|
|
49
|
+
clearTimeout(timeout);
|
|
50
|
+
w(gray("\nForce closing...\n"));
|
|
51
|
+
server.close(true);
|
|
52
|
+
resolve();
|
|
53
|
+
};
|
|
44
54
|
timeout = setTimeout(() => {
|
|
45
55
|
w(gray(`\nForce closing connections in ${forceShutdown}s...`));
|
|
46
56
|
timeout = setTimeout(() => {
|
package/dist/_chunks/_utils.mjs
CHANGED
|
@@ -15,14 +15,16 @@ function fmtURL(host, port, secure) {
|
|
|
15
15
|
}
|
|
16
16
|
function printListening(opts, url) {
|
|
17
17
|
if (!url || (opts.silent ?? globalThis.process?.env?.TEST)) return;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_url.hostname
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
let additionalInfo = "";
|
|
19
|
+
try {
|
|
20
|
+
const _url = new URL(url);
|
|
21
|
+
if (_url.hostname === "[::]" || _url.hostname === "0.0.0.0") {
|
|
22
|
+
_url.hostname = "localhost";
|
|
23
|
+
url = _url.href;
|
|
24
|
+
additionalInfo = " (all interfaces)";
|
|
25
|
+
}
|
|
26
|
+
} catch {}
|
|
24
27
|
let listeningOn = `➜ Listening on:`;
|
|
25
|
-
let additionalInfo = allInterfaces ? " (all interfaces)" : "";
|
|
26
28
|
if (globalThis.process.stdout?.isTTY) {
|
|
27
29
|
listeningOn = `\u001B[32m${listeningOn}\u001B[0m`;
|
|
28
30
|
url = `\u001B[36m${url}\u001B[0m`;
|
package/dist/adapters/node.mjs
CHANGED
|
@@ -210,7 +210,6 @@ const NodeRequest = /* @__PURE__ */ (() => {
|
|
|
210
210
|
const { req, res } = this.runtime.node;
|
|
211
211
|
const abortController = this.#abortController;
|
|
212
212
|
const abort = (err) => abortController.abort?.(err);
|
|
213
|
-
req.once("error", abort);
|
|
214
213
|
if (res) res.once("close", () => {
|
|
215
214
|
const reqError = req.errored;
|
|
216
215
|
if (reqError) abort(reqError);
|
|
@@ -641,7 +640,7 @@ var NodeServer = class {
|
|
|
641
640
|
async close(closeAll) {
|
|
642
641
|
await Promise.all([this.#wait.wait(), new Promise((resolve, reject) => {
|
|
643
642
|
const server = this.node?.server;
|
|
644
|
-
if (!server) return resolve();
|
|
643
|
+
if (!server || !server.listening) return resolve();
|
|
645
644
|
if (closeAll && "closeAllConnections" in server) server.closeAllConnections();
|
|
646
645
|
server.close((error) => error ? reject(error) : resolve());
|
|
647
646
|
})]);
|
|
@@ -4,7 +4,7 @@ import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
|
4
4
|
const FastURL = URL;
|
|
5
5
|
const FastResponse = Response;
|
|
6
6
|
const isBrowserWindow = typeof window !== "undefined" && typeof navigator !== "undefined";
|
|
7
|
-
const isServiceWorker =
|
|
7
|
+
const isServiceWorker = typeof self !== "undefined" && "skipWaiting" in self;
|
|
8
8
|
function serve(options) {
|
|
9
9
|
return new ServiceWorkerServer(options);
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srvx",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Universal Server API based on web platform standards. Works seamlessly with Deno, Bun and Node.js.",
|
|
5
5
|
"homepage": "https://srvx.h3.dev",
|
|
6
6
|
"repository": "h3js/srvx",
|
|
@@ -51,46 +51,47 @@
|
|
|
51
51
|
"srvx": "./bin/srvx.mjs",
|
|
52
52
|
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|
|
53
53
|
"test:node-compat:deno": "deno run vitest test/node.test",
|
|
54
|
-
"test:node-compat:bun": "bun
|
|
55
|
-
"test:types": "
|
|
54
|
+
"test:node-compat:bun": "bun vitest test/node.test.ts",
|
|
55
|
+
"test:types": "tsgo --noEmit --skipLibCheck",
|
|
56
56
|
"vitest": "vitest"
|
|
57
57
|
},
|
|
58
58
|
"resolutions": {
|
|
59
59
|
"srvx": "link:."
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@cloudflare/workers-types": "^4.
|
|
63
|
-
"@hono/node-server": "^1.19.
|
|
62
|
+
"@cloudflare/workers-types": "^4.20260117.0",
|
|
63
|
+
"@hono/node-server": "^1.19.9",
|
|
64
64
|
"@mitata/counters": "^0.0.8",
|
|
65
65
|
"@mjackson/node-fetch-server": "^0.7.0",
|
|
66
|
-
"@types/bun": "^1.3.
|
|
66
|
+
"@types/bun": "^1.3.6",
|
|
67
67
|
"@types/deno": "^2.5.0",
|
|
68
68
|
"@types/express": "^5.0.6",
|
|
69
|
-
"@types/node": "^25.0.
|
|
69
|
+
"@types/node": "^25.0.9",
|
|
70
70
|
"@types/node-forge": "^1.3.14",
|
|
71
|
-
"@types/serviceworker": "^0.0.
|
|
72
|
-
"@
|
|
73
|
-
"@
|
|
71
|
+
"@types/serviceworker": "^0.0.176",
|
|
72
|
+
"@typescript/native-preview": "^7.0.0-dev.20260117.1",
|
|
73
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
74
|
+
"@whatwg-node/server": "^0.10.18",
|
|
74
75
|
"automd": "^0.4.2",
|
|
75
76
|
"changelogen": "^0.6.2",
|
|
76
77
|
"eslint": "^9.39.2",
|
|
77
|
-
"eslint-config-unjs": "^0.
|
|
78
|
+
"eslint-config-unjs": "^0.6.2",
|
|
78
79
|
"execa": "^9.6.1",
|
|
79
80
|
"express": "^5.2.1",
|
|
80
|
-
"fastify": "^5.
|
|
81
|
+
"fastify": "^5.7.1",
|
|
81
82
|
"get-port-please": "^3.2.0",
|
|
82
83
|
"mdbox": "^0.1.1",
|
|
83
84
|
"mitata": "^1.0.34",
|
|
84
85
|
"node-forge": "^1.3.3",
|
|
85
|
-
"obuild": "^0.4.
|
|
86
|
-
"prettier": "^3.
|
|
87
|
-
"srvx-release": "npm:srvx@^0.
|
|
86
|
+
"obuild": "^0.4.14",
|
|
87
|
+
"prettier": "^3.8.0",
|
|
88
|
+
"srvx-release": "npm:srvx@^0.10.0",
|
|
88
89
|
"tslib": "^2.8.1",
|
|
89
90
|
"typescript": "^5.9.3",
|
|
90
|
-
"undici": "^7.
|
|
91
|
-
"vitest": "^4.0.
|
|
91
|
+
"undici": "^7.18.2",
|
|
92
|
+
"vitest": "^4.0.17"
|
|
92
93
|
},
|
|
93
|
-
"packageManager": "pnpm@10.
|
|
94
|
+
"packageManager": "pnpm@10.28.0",
|
|
94
95
|
"engines": {
|
|
95
96
|
"node": ">=20.16.0"
|
|
96
97
|
}
|