Skip to content

Commit ec71d61

Browse files
committed
Fix error in tests
1 parent cbdcf88 commit ec71d61

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "json-stream-stringify",
33
"description": "JSON.Stringify as a readable stream",
4-
"version": "3.1.2",
4+
"version": "3.1.3",
55
"license": "MIT",
66
"author": "Faleij <[email protected]> (https://github.com/faleij)",
77
"repository": {
@@ -71,7 +71,7 @@
7171
"typescript": "^4.7.4"
7272
},
7373
"volta": {
74-
"node": "18.16.0"
74+
"node": "16.20.2"
7575
},
7676
"engines": {
7777
"node": ">=7.10.1"

src/JsonStreamStringify.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,12 @@ export class JsonStreamStringify extends Readable {
494494
this.readState = ReadState.Reading;
495495
this.pushCalled = false;
496496
let p;
497-
while (!this.pushCalled && this.item !== this.root && !this.destroyed) {
497+
while (!this.pushCalled && this.item !== this.root && this.buffer !== undefined) {
498498
p = this.item.read(size);
499499
// eslint-disable-next-line no-await-in-loop
500500
if (p) await p;
501501
}
502+
if (this.buffer === undefined) return;
502503
if (this.item === this.root) {
503504
if (this.buffer.length) this.push(this.buffer);
504505
this.push(null);
@@ -513,6 +514,7 @@ export class JsonStreamStringify extends Readable {
513514
}
514515

515516
private cleanup() {
517+
this.readState = ReadState.Consumed;
516518
this.buffer = undefined;
517519
this.visited = undefined;
518520
this.item = undefined;

0 commit comments

Comments
 (0)