destroy streams on client abort
This commit is contained in:
parent
f54f3ccaa2
commit
4904867c3b
2 changed files with 5 additions and 1 deletions
|
@ -25,6 +25,10 @@ module.exports = async function(req, res) {
|
|||
try {
|
||||
const limiter = new Limiter(encryptedSize(config.max_file_size));
|
||||
const fileStream = req.pipe(limiter);
|
||||
|
||||
// .pipe() does not propagate errors correctly...
|
||||
req.on('error', err => fileStream.destroy(err));
|
||||
|
||||
//this hasn't been updated to expiration time setting yet
|
||||
//if you want to fallback to this code add this
|
||||
await storage.set(newId, fileStream, meta, config.default_expire_seconds);
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports = function(ws, req) {
|
|||
|
||||
ws.on('close', e => {
|
||||
if (e !== 1000 && fileStream !== undefined) {
|
||||
fileStream.destroy();
|
||||
fileStream.destroy(new Error('ws closed with error'));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue