Skip to content

Commit fb7904b

Browse files
readablecursorstream uses async next variant
1 parent 15e8225 commit fb7904b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,21 @@ class ReadableCursorStream extends Readable {
880880
}
881881

882882
private _readNext() {
883-
callbackify(next)(this._cursor, true, (err, result) => {
884-
if (err) {
883+
next(this._cursor, true).then(
884+
result => {
885+
if (result == null) {
886+
this.push(null);
887+
} else if (this.destroyed) {
888+
this._cursor.close().catch(() => null);
889+
} else {
890+
if (this.push(result)) {
891+
return this._readNext();
892+
}
893+
894+
this._readInProgress = false;
895+
}
896+
},
897+
err => {
885898
// NOTE: This is questionable, but we have a test backing the behavior. It seems the
886899
// desired behavior is that a stream ends cleanly when a user explicitly closes
887900
// a client during iteration. Alternatively, we could do the "right" thing and
@@ -910,18 +923,6 @@ class ReadableCursorStream extends Readable {
910923
// See NODE-4475.
911924
return this.destroy(err);
912925
}
913-
914-
if (result == null) {
915-
this.push(null);
916-
} else if (this.destroyed) {
917-
this._cursor.close().catch(() => null);
918-
} else {
919-
if (this.push(result)) {
920-
return this._readNext();
921-
}
922-
923-
this._readInProgress = false;
924-
}
925-
});
926+
);
926927
}
927928
}

0 commit comments

Comments
 (0)