Skip to content

Commit 1784fce

Browse files
client: fix Fetcher.ts failure on Node v14
1 parent a06ebde commit 1784fce

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.github/workflows/client-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
node-version: [12]
23+
node-version: [12,14]
2424
steps:
2525
- name: Use Node.js ${{ matrix.node-version }}
2626
uses: actions/setup-node@v1

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)