srvx 0.11.9 → 0.11.10

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/adapters/node.mjs +12 -17
  2. package/package.json +11 -11
@@ -4,6 +4,7 @@ import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as prin
4
4
  import { n as gracefulShutdownPlugin, r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
5
5
  import nodeHTTP, { IncomingMessage, ServerResponse } from "node:http";
6
6
  import { Duplex, PassThrough, Readable } from "node:stream";
7
+ import { pipeline } from "node:stream/promises";
7
8
  import nodeHTTPS from "node:https";
8
9
  import nodeHTTP2 from "node:http2";
9
10
  //#region src/adapters/_node/send.ts
@@ -17,10 +18,7 @@ async function sendNodeResponse(nodeRes, webRes) {
17
18
  writeHead(nodeRes, res.status, res.statusText, res.headers);
18
19
  if (res.body) {
19
20
  if (res.body instanceof ReadableStream) return streamBody(res.body, nodeRes);
20
- else if (typeof res.body?.pipe === "function") {
21
- res.body.pipe(nodeRes);
22
- return new Promise((resolve) => nodeRes.on("close", resolve));
23
- }
21
+ else if (typeof res.body?.pipe === "function") return pipeBody(res.body, nodeRes);
24
22
  nodeRes.write(res.body);
25
23
  }
26
24
  return endNodeResponse(nodeRes);
@@ -37,6 +35,13 @@ function writeHead(nodeRes, status, statusText, rawHeaders) {
37
35
  function endNodeResponse(nodeRes) {
38
36
  return new Promise((resolve) => nodeRes.end(resolve));
39
37
  }
38
+ function pipeBody(stream, nodeRes) {
39
+ if (nodeRes.destroyed) {
40
+ stream.destroy();
41
+ return;
42
+ }
43
+ return pipeline(stream, nodeRes).catch(() => {});
44
+ }
40
45
  function streamBody(stream, nodeRes) {
41
46
  if (nodeRes.destroyed) {
42
47
  stream.cancel();
@@ -80,9 +85,8 @@ var NodeRequestURL = class extends FastURL {
80
85
  const pathname = qIndex === -1 ? path : path?.slice(0, qIndex) || "/";
81
86
  const search = qIndex === -1 ? "" : path?.slice(qIndex) || "";
82
87
  let host = req.headers.host || req.headers[":authority"];
83
- if (host) {
84
- if (!HOST_RE.test(host)) throw new TypeError(`Invalid host header: ${host}`);
85
- } else if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`;
88
+ if (host && !HOST_RE.test(host)) host = "_invalid_";
89
+ else if (!host) if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`;
86
90
  else host = "localhost";
87
91
  const protocol = req.socket?.encrypted || req.headers["x-forwarded-proto"] === "https" || req.headers[":scheme"] === "https" ? "https:" : "http:";
88
92
  super({
@@ -144,17 +148,8 @@ const NodeRequestHeaders = /* @__PURE__ */ (() => {
144
148
  const value = this.#req.headers["set-cookie"];
145
149
  return Array.isArray(value) ? value : value ? [value] : [];
146
150
  }
147
- *_entries() {
148
- const rawHeaders = this.#req.rawHeaders;
149
- const len = rawHeaders.length;
150
- for (let i = 0; i < len; i += 2) {
151
- const key = rawHeaders[i];
152
- if (key.charCodeAt(0) === 58) continue;
153
- yield [key.toLowerCase(), rawHeaders[i + 1]];
154
- }
155
- }
156
151
  entries() {
157
- return this.#headers ? this.#headers.entries() : this._entries();
152
+ return this._headers.entries();
158
153
  }
159
154
  [Symbol.iterator]() {
160
155
  return this.entries();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "srvx",
3
- "version": "0.11.9",
3
+ "version": "0.11.10",
4
4
  "description": "Universal Server.",
5
5
  "homepage": "https://srvx.h3.dev",
6
6
  "license": "MIT",
@@ -59,7 +59,7 @@
59
59
  "vitest": "vitest"
60
60
  },
61
61
  "devDependencies": {
62
- "@cloudflare/workers-types": "^4.20260307.1",
62
+ "@cloudflare/workers-types": "^4.20260313.1",
63
63
  "@hono/node-server": "^1.19.11",
64
64
  "@mitata/counters": "^0.0.8",
65
65
  "@mjackson/node-fetch-server": "^0.7.0",
@@ -67,11 +67,11 @@
67
67
  "@types/bun": "^1.3.10",
68
68
  "@types/deno": "^2.5.0",
69
69
  "@types/express": "^5.0.6",
70
- "@types/node": "^25.3.5",
70
+ "@types/node": "^25.5.0",
71
71
  "@types/node-forge": "^1.3.14",
72
72
  "@types/serviceworker": "^0.0.193",
73
- "@typescript/native-preview": "7.0.0-dev.20260309.1",
74
- "@vitest/coverage-v8": "^4.0.18",
73
+ "@typescript/native-preview": "^7.0.0-dev.20260315.1",
74
+ "@vitest/coverage-v8": "^4.1.0",
75
75
  "@whatwg-node/server": "^0.10.18",
76
76
  "automd": "^0.4.3",
77
77
  "changelogen": "^0.6.2",
@@ -84,13 +84,13 @@
84
84
  "mitata": "^1.0.34",
85
85
  "node-forge": "^1.3.3",
86
86
  "obuild": "^0.4.32",
87
- "oxfmt": "^0.36.0",
88
- "oxlint": "^1.51.0",
89
- "srvx-release": "npm:srvx@^0.11.8",
87
+ "oxfmt": "^0.40.0",
88
+ "oxlint": "^1.55.0",
89
+ "srvx-release": "npm:srvx@^0.11.9",
90
90
  "tslib": "^2.8.1",
91
91
  "typescript": "^5.9.3",
92
- "undici": "^7.22.0",
93
- "vitest": "^4.0.18"
92
+ "undici": "^7.24.3",
93
+ "vitest": "^4.1.0"
94
94
  },
95
95
  "resolutions": {
96
96
  "srvx": "link:."
@@ -98,5 +98,5 @@
98
98
  "engines": {
99
99
  "node": ">=20.16.0"
100
100
  },
101
- "packageManager": "pnpm@10.30.2"
101
+ "packageManager": "pnpm@10.32.1"
102
102
  }