From dd46841020a1757c6e46ebfc32f79403fe10ebe5 Mon Sep 17 00:00:00 2001 From: Mark David Avery Date: Fri, 7 Oct 2022 00:30:26 -0700 Subject: [PATCH] fix: moved to using nextTick rather thanthe query query e to legacy node (nod 18) --- lib/parse.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/parse.js b/lib/parse.js index 8a8e86b7..4b85915c 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -28,6 +28,7 @@ const maxMetaEntrySize = 1024 * 1024 const Entry = require('./read-entry.js') const Pax = require('./pax.js') const zlib = require('minizlib') +const { nextTick } = require('process') const gzipHeader = Buffer.from([0x1f, 0x8b]) const STATE = Symbol('state') @@ -59,6 +60,7 @@ const DONE = Symbol('onDone') const SAW_VALID_ENTRY = Symbol('sawValidEntry') const SAW_NULL_BLOCK = Symbol('sawNullBlock') const SAW_EOF = Symbol('sawEOF') +const CLOSESTREAM = Symbol('closeStream') const noop = _ => true @@ -114,7 +116,7 @@ module.exports = warner(class Parser extends EE { this[SAW_NULL_BLOCK] = false this[SAW_EOF] = false - this.on('end', () => queueMicrotask(() => this.emit('close'))) + this.on('end', () => this[CLOSESTREAM]()) if (typeof opt.onwarn === 'function') { this.on('warn', opt.onwarn) @@ -219,6 +221,10 @@ module.exports = warner(class Parser extends EE { } } + [CLOSESTREAM] () { + nextTick(() => this.emit('close')) + } + [PROCESSENTRY] (entry) { let go = true