Skip to content

Commit

Permalink
fix: moved to using nextTick rather thanthe query query e to legacy n…
Browse files Browse the repository at this point in the history
…ode (nod 18)
  • Loading branch information
webark committed Oct 7, 2022
1 parent 37ef247 commit dd46841
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -219,6 +221,10 @@ module.exports = warner(class Parser extends EE {
}
}

[CLOSESTREAM] () {
nextTick(() => this.emit('close'))
}

[PROCESSENTRY] (entry) {
let go = true

Expand Down

0 comments on commit dd46841

Please sign in to comment.