diff --git a/lib/pcapConverter.js b/lib/pcapConverter.js index 2b250c8..cf52dea 100644 --- a/lib/pcapConverter.js +++ b/lib/pcapConverter.js @@ -173,9 +173,12 @@ PcapConverter.prototype.convertStream = function(inputStream) { } return; } - var timePassed = new Date() - tempFile.createdOn; + var timePassed = Date.now() - tempFile.createdOn; - if ((timePassed >= 5000 && tempFile.packetCount > 0) || tempFile.packetCount >= 1000 || (tempFile.packetCount > 0 && parseOnEndOccured)) { + if ( + (timePassed >= 5000 && tempFile.packetCount > 0) + || tempFile.packetCount >= 1000 + || (tempFile.packetCount > 0 && parseOnEndOccured && packetQueue.length() == 0)) { var oldTempFile = tempFile; tempFile = null; return fs.close(oldTempFile.fd, function(err) {