dominhhai / koa-busboy

Upload files with Busboy
https://www.npmjs.com/package/koa-busboy
MIT License
32 stars 5 forks source link

Unhandled promise rejection #9

Open kapvode opened 5 years ago

kapvode commented 5 years ago

I've encountered an unhandled promise rejection that I was able to track down and fix with the following patch.

diff --git a/extract.js b/extract.js
index 18e614e..e657bc3 100644
--- a/extract.js
+++ b/extract.js
@@ -27,7 +27,7 @@ module.exports = function (req, dest, fnDestFilename, opts = {}) {

             resolve(rs)
           })
-      }))
+      }).catch(reject))
     })

     busboy.on('field', (name, value) => {

I think it happened when there was a problem with GlusterFS. I was able to reproduce it using SSHFS, but it's not simple.

There is a Promise.all(files).catch(reject) further down, but it's too late.