Skip to content

Commit a6e2f12

Browse files
committed
audit: Make sure we hide stream errors on background audit submissions
Credit: @iarna
1 parent 8dbf726 commit a6e2f12

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/install/audit.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ function submitForInstallReport (auditData) {
4040
// we don't care about the response so destroy the stream if we can, or leave it flowing
4141
// so it can eventually finish and clean up after itself
4242
fetchAudit(url.resolve(reg, '/-/npm/v1/security/audits/quick'))
43-
.then((_) => _.body.destroy ? _.body.destroy() : _.body.resume(), (_) => {})
43+
.then((_) => {
44+
_.body.on('error', () => {})
45+
if (_.body.destroy) {
46+
_.body.destroy()
47+
} else {
48+
_.body.resume()
49+
}
50+
}, () => {})
4451
})
4552
perf.emit('time', 'audit submit')
4653
return fetchAudit('/-/npm/v1/security/audits/quick', body).then((response) => {

0 commit comments

Comments
 (0)