Skip to content

Commit 92e8598

Browse files
use bigint for cursor id
1 parent e9b652f commit 92e8598

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/cmap/wire_protocol/responses.ts

Lines changed: 2 additions & 6 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 {
@@ -247,12 +247,8 @@ export class CursorResponse extends MongoDBResponse {
247247
}
248248

249249
public get id(): Long {
250-
if (!this.cursor.has('id')) {
251-
throw new MongoUnexpectedServerResponseError('"id" is missing');
252-
}
253250
try {
254-
const cursorId = this.cursor.get('id', BSONType.long, false);
255-
return cursorId != null ? Long.fromBigInt(cursorId) : Long.fromBigInt(0n);
251+
return Long.fromBigInt(this.cursor.get('id', BSONType.long, true));
256252
} catch (cause) {
257253
throw new MongoUnexpectedServerResponseError(cause.message, { cause });
258254
}

0 commit comments

Comments
 (0)