Skip to content

Commit eb2e4c8

Browse files
authored
Merge pull request #1022 from ethereumjs/fix-client-node-tests
client: fix Fetcher.ts failure on Node v14
2 parents 582b4ef + f805870 commit eb2e4c8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/client/lib/sync/fetcher/fetcher.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class Fetcher extends Readable {
4545
protected in: any
4646
protected out: any
4747
protected total: number
48-
protected processed: number
48+
protected processed: number // number of processed tasks, awaiting the write job
49+
protected finished: number // number of tasks which are both processed and also finished writing
4950
protected running: boolean
5051
protected reading: boolean
5152
private _readableState: any
@@ -69,6 +70,7 @@ export class Fetcher extends Readable {
6970
this.out = new Heap({ comparBefore: (a: any, b: any) => a.index < b.index })
7071
this.total = 0
7172
this.processed = 0
73+
this.finished = 0
7274
this.running = false
7375
this.reading = false
7476
}
@@ -212,6 +214,7 @@ export class Fetcher extends Readable {
212214
const _write = async (result: any, encoding: any, cb: Function) => {
213215
try {
214216
await this.store(result)
217+
this.finished++
215218
this.emit('fetched', result)
216219
cb()
217220
} catch (error) {
@@ -262,7 +265,7 @@ export class Fetcher extends Readable {
262265
this.running = true
263266
while (this.running) {
264267
if (!this.next()) {
265-
if (this.processed === this.total) {
268+
if (this.finished === this.total) {
266269
this.push(null)
267270
}
268271
await this.wait()

0 commit comments

Comments
 (0)