cwresdev 0.1.5 → 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.5",
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 = {
package/src/server.js CHANGED
@@ -298,9 +298,51 @@ async function startDevServer(config) {
298
298
  });
299
299
 
300
300
  let reloadTimer = null;
301
+ const ignored = (config.watchIgnored || []).map((pattern) => {
302
+ if (typeof pattern === "function") return pattern;
303
+ if (pattern instanceof RegExp) return pattern;
304
+ if (typeof pattern !== "string") return () => false;
305
+
306
+ const normalized = pattern.replace(/\\/g, "/");
307
+
308
+ // **/segment/** → match paths containing /segment/
309
+ if (normalized.startsWith("**/") && normalized.endsWith("/**")) {
310
+ const segment = normalized.slice(3, -3);
311
+ return (filePath) => filePath.replace(/\\/g, "/").includes(`/${segment}/`);
312
+ }
313
+
314
+ if (normalized.startsWith("**/")) {
315
+ const tail = normalized.slice(3);
316
+
317
+ // **/*suffix → basename ends with suffix (e.g. **/*~)
318
+ if (tail.startsWith("*")) {
319
+ const suffix = tail.slice(1);
320
+ return (filePath) => path.basename(filePath).endsWith(suffix);
321
+ }
322
+
323
+ // **/prefix* → basename starts with prefix (e.g. **/~*)
324
+ if (tail.endsWith("*") && !tail.slice(0, -1).includes("*")) {
325
+ const prefix = tail.slice(0, -1);
326
+ return (filePath) => path.basename(filePath).startsWith(prefix);
327
+ }
328
+
329
+ // **/*.ext → match by extension (e.g. **/*.tmp)
330
+ if (tail.includes("*.")) {
331
+ const ext = tail.slice(tail.indexOf("*.") + 1);
332
+ return (filePath) => path.basename(filePath).endsWith(ext);
333
+ }
334
+
335
+ // **/name or **/dir/name → match end of path (e.g. **/Thumbs.db, **/data/.xml)
336
+ return (filePath) => filePath.replace(/\\/g, "/").endsWith(`/${tail}`);
337
+ }
338
+
339
+ // No glob metacharacters: exact match
340
+ return (filePath) => filePath.replace(/\\/g, "/") === normalized;
341
+ });
342
+
301
343
  const watcher = chokidar.watch(config.docRoot, {
302
344
  ignoreInitial: true,
303
- ignored: config.watchIgnored,
345
+ ignored,
304
346
  });
305
347
 
306
348
  watcher.on("all", (eventName, filePath) => {