From e41a64379214836b7ea4b06a7492202d2e8dc8df Mon Sep 17 00:00:00 2001 From: Uzlopak Date: Thu, 9 Jun 2022 21:43:21 +0200 Subject: [PATCH] handle unpipeing, cancelling or destroying of busboy accordingly (#81) --- lib/types/multipart.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/types/multipart.js b/lib/types/multipart.js index e02b9d9..1b3cb01 100644 --- a/lib/types/multipart.js +++ b/lib/types/multipart.js @@ -172,6 +172,15 @@ function Multipart (boy, cfg) { ++nends const file = new FileStream(fileOpts) curFile = file + boy.on('unpipe', function () { + file.destroy() + }) + boy.on('cancel', function () { + file.destroy() + }) + boy.on('destroy', function () { + file.destroy() + }) file.on('end', function () { --nends self._pause = false