Skip to content

Commit 041d287

Browse files
use bigint for cursor id
1 parent e1a8678 commit 041d287

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/cmap/wire_protocol/responses.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class CursorResponse extends MongoDBResponse {
232232
* It is an optimization to avoid an extra getMore when the limit has been reached
233233
*/
234234
static get emptyGetMore(): CursorResponse {
235-
return new CursorResponse(serialize({ ok: 1, cursor: { id: 0, nextBatch: [] } }));
235+
return new CursorResponse(serialize({ ok: 1, cursor: { id: 0n, nextBatch: [] } }));
236236
}
237237

238238
static override is(value: unknown): value is CursorResponse {
@@ -248,8 +248,7 @@ export class CursorResponse extends MongoDBResponse {
248248

249249
public get id(): Long {
250250
try {
251-
const cursorId = this.cursor.get('id', BSONType.long, false);
252-
return cursorId ? Long.fromBigInt(cursorId) : Long.fromBigInt(0n);
251+
return Long.fromBigInt(this.cursor.get('id', BSONType.long, true));
253252
} catch (cause) {
254253
throw new MongoUnexpectedServerResponseError(cause.message, { cause });
255254
}

0 commit comments

Comments
 (0)