Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes Stream cursor methods isExhausted(), hasNext() broken #208

Closed
SurfinScott opened this issue Dec 5, 2019 · 2 comments
Closed

Changes Stream cursor methods isExhausted(), hasNext() broken #208

SurfinScott opened this issue Dec 5, 2019 · 2 comments
Assignees
Labels

Comments

@SurfinScott
Copy link

MacBook-Pro(mongod-4.0.13-82-g11446b4)[PRIMARY:replset] test> var wc = db.getSiblingDB("test").c.watch();
MacBook-Pro(mongod-4.0.13-82-g11446b4)[PRIMARY:replset] test> while (!wc.isExhausted()) { if ( wc.hasNext() ) { printjson( wc.next() ); } }
2019-12-05T10:48:59.511-0800 E QUERY [js] TypeError: wc.isExhausted is not a function :
@(shell):1:9

MacBook-Pro(mongod-4.0.13-82-g11446b4)[PRIMARY:replset] test> wc
{
"cursor": {
"firstBatch": [ ],
"postBatchResumeToken": {
"_data": "825DE95136000000022B0229296E5A100431CFD77563DF4169A26F16097658B2F804"
},
"id": NumberLong("7421492416343123823"),
"ns": "test.c"
},
"ok": 1,
"operationTime": Timestamp(1575571766, 1),
"$clusterTime": {
"clusterTime": Timestamp(1575571766, 1),
"signature": {
"hash": BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId": NumberLong("0")
}
}
}

MacBook-Pro(mongod-4.0.13-82-g11446b4)[PRIMARY:replset] test> wc.hasNext()
2019-12-05T10:51:48.188-0800 E QUERY [js] TypeError: wc.hasNext is not a function :
@(shell):1:1

Did not test wc.next().

@stennie
Copy link
Collaborator

stennie commented Dec 6, 2019

@SurfinScott Thanks for the bug report! Looks like this is an unexpected side effect of Mongo Hacker's current override of the aggregate() prototype.

@stennie stennie self-assigned this Dec 6, 2019
@stennie stennie added the bug label Dec 6, 2019
@stennie stennie closed this as completed in d86eda5 Dec 6, 2019
@stennie
Copy link
Collaborator

stennie commented Dec 6, 2019

@SurfinScott Fixed this in the 0.1.1 release. I discovered there were a few scenarios where Mongo Hacker was emulating cursor behaviour (from the olden days when aggregate only returned an inline result) rather than returning the real aggregate cursor.

Cheers,
Stennie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants