cwresdev 0.1.6 → 0.1.8

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/bin/cwrespro.js CHANGED
@@ -13,6 +13,25 @@ function openBrowser(url) {
13
13
  child.unref();
14
14
  }
15
15
 
16
+ // Guard against Node.js v24+ internal undici assertion crash (ERR_ASSERTION
17
+ // in Parser.finish when upstream sockets close mid-stream). This is a known
18
+ // engine-level bug; swallowing it here keeps the dev server alive.
19
+ process.on("uncaughtException", (err) => {
20
+ if (
21
+ err &&
22
+ err.code === "ERR_ASSERTION" &&
23
+ err.stack &&
24
+ err.stack.includes("undici")
25
+ ) {
26
+ process.stderr.write(
27
+ "[cwrespro] Warning: transient upstream connection reset (Node.js undici bug); ignoring.\n"
28
+ );
29
+ return;
30
+ }
31
+
32
+ throw err;
33
+ });
34
+
16
35
  async function main() {
17
36
  if (process.platform !== "win32") {
18
37
  throw new Error("cwrespro currently supports Windows only.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cwresdev",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "private": false,
package/src/proxy.js CHANGED
@@ -132,7 +132,15 @@ async function proxyRequest({ req, res, target, injectHtml = false, injectCookie
132
132
  return;
133
133
  }
134
134
 
135
- Readable.fromWeb(upstream.body).pipe(res);
135
+ const readable = Readable.fromWeb(upstream.body);
136
+
137
+ readable.on("error", (err) => {
138
+ if (!res.writableEnded) {
139
+ res.end();
140
+ }
141
+ });
142
+
143
+ readable.pipe(res);
136
144
  }
137
145
 
138
146
  module.exports = {