From 5f43ec2ff8cce7f0dd6be214129c2659f6934072 Mon Sep 17 00:00:00 2001 From: yangh Date: Thu, 23 Sep 2021 19:22:56 +0800 Subject: [PATCH] fix: Empty part will hang the process --- lib/Dicer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Dicer.js b/lib/Dicer.js index 9d580cb..4c21db7 100644 --- a/lib/Dicer.js +++ b/lib/Dicer.js @@ -203,7 +203,9 @@ Dicer.prototype._oninfo = function(isMatch, data, start, end) { if (this._isPreamble) this._isPreamble = false; else { - ++this._parts; + // Only the non-empty part will be counted. + // Because the onEnd function is only called in the onHeader event. + (end > start) && ++this._parts; this._part.on('end', function() { if (--self._parts === 0) { if (self._finished) {