« get me outta code hell

write: live-dev-server: end file responses less enthusiastically - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-11 09:47:00 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-11 09:47:00 -0300
commit86068ab18e4a82754dbd055ebf21e3a1ec5ead07 (patch)
tree09186079a8d481d5397f7e1c9f62318c9b588485 /src
parentf2381a1ee1e20dea5b23ea9d20c7a85b5b1c1c45 (diff)
write: live-dev-server: end file responses less enthusiastically
This seems to be a bit more reliable, although it'll probably take
a little more memory while serving larger files.
Diffstat (limited to 'src')
-rw-r--r--src/write/build-modes/live-dev-server.js11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index d4efd177..1339c322 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -1,8 +1,6 @@
 import * as http from 'node:http';
-import {createReadStream} from 'node:fs';
-import {stat} from 'node:fs/promises';
+import {readFile, stat} from 'node:fs/promises';
 import * as path from 'node:path';
-import {pipeline} from 'node:stream/promises'
 
 import {logInfo, logWarn, progressCallAll} from '#cli';
 import {watchContentDependencies} from '#content-dependencies';
@@ -224,7 +222,7 @@ export async function go({
         'gif': 'image/gif',
         'ico': 'image/vnd.microsoft.icon',
         'jpg': 'image/jpeg',
-        'jpeg:': 'image/jpeg',
+        'jpeg': 'image/jpeg',
         'js': 'text/javascript',
         'mjs': 'text/javascript',
         'mp3': 'audio/mpeg',
@@ -249,13 +247,12 @@ export async function go({
 
       try {
         const {size} = await stat(filePath);
+        const buffer = await readFile(filePath)
         response.writeHead(200, contentType ? {
           'Content-Type': contentType,
           'Content-Length': size,
         } : {});
-        await pipeline(
-          createReadStream(filePath),
-          response);
+        response.end(buffer);
         if (loudResponses) console.log(`${requestHead} [200] ${pathname}`);
       } catch (error) {
         response.writeHead(500, contentTypePlain);