From 150d8747325fc95f8532a371f2b6e2eaaf1d893c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 9 Oct 2024 19:16:20 -0300 Subject: write: live-dev-server: fix premature close crash in pipeline --- src/write/build-modes/live-dev-server.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/write/build-modes') 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`)})`); -- cgit 1.3.0-6-gf8a5