« get me outta code hell

write: live-dev-server: fix premature close crash in pipeline - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-10-09 19:16:20 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-10-09 19:16:20 -0300
commit150d8747325fc95f8532a371f2b6e2eaaf1d893c (patch)
tree44658271542caf7b092d9b3d4a8e0c8130f7b13f /src/write
parentec34eb807178050fab744996007a2ff8038cde64 (diff)
write: live-dev-server: fix premature close crash in pipeline
Diffstat (limited to 'src/write')
-rw-r--r--src/write/build-modes/live-dev-server.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index 42a4ab74..f6eec334 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -321,7 +321,16 @@ export async function go({
         'Content-Length': size,
       });
 
-      await pipeline(fd.createReadStream(), response);
+      try {
+        await pipeline(fd.createReadStream(), response);
+      } catch (error) {
+        if (error.code === 'ERR_STREAM_PREMATURE_CLOSE') {
+          // Connection was dropped, this is OK.
+          return;
+        } else {
+          throw error;
+        }
+      }
 
       if (loudResponses) console.log(`${requestHead} [200] ${pathname} (${colors.magenta(`web route`)})`);