mirror of
https://github.com/PretendoNetwork/BOSS.git
synced 2026-04-20 14:07:44 -05:00
fix: Use Stream.pipeline for response stream to properly close s3 stream
This commit is contained in:
parent
96d2ccf8a8
commit
1fd43ce0f7
|
|
@ -2,6 +2,7 @@ import express from 'express';
|
|||
import subdomain from 'express-subdomain';
|
||||
import { getTaskFile } from '@/database';
|
||||
import { getCDNFileStream } from '@/util';
|
||||
import { Stream } from 'node:stream';
|
||||
|
||||
const npdl = express.Router();
|
||||
|
||||
|
|
@ -37,7 +38,13 @@ npdl.get([
|
|||
}
|
||||
|
||||
response.setHeader('Last-Modified', new Date(Number(file.updated)).toUTCString());
|
||||
readStream.pipe(response);
|
||||
|
||||
Stream.pipeline(readStream, response, (err) => {
|
||||
if (err) {
|
||||
console.error('Error with response stream: ', err.message);
|
||||
response.end();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const router = express.Router();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user