mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-04 02:31:36 +00:00
fix(docker-server): handle createReadStream errors
Attach an error listener before piping so mid-flight read errors (truncated file, permission change) cleanly destroy the response instead of being silently swallowed. Made-with: Cursor
This commit is contained in:
parent
856d9a4b97
commit
e449decd0b
1 changed files with 3 additions and 1 deletions
|
|
@ -58,7 +58,9 @@ const server = createServer(async (req, res) => {
|
|||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'require-corp',
|
||||
});
|
||||
createReadStream(filePath).pipe(res);
|
||||
const stream = createReadStream(filePath);
|
||||
stream.on('error', () => res.destroy());
|
||||
stream.pipe(res);
|
||||
} catch (error) {
|
||||
res.writeHead(500);
|
||||
res.end(error instanceof Error ? error.message : 'Internal server error');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue