-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(ChangeStream): hasNext/next should work after resume #2333
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
Conversation
@@ -4,7 +4,7 @@ language: node_js | |||
branches: | |||
only: | |||
- master | |||
- 3.6 | |||
- next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidentally left this change in the previous merge from 3.6
, so I reverted it here. But really we should just delete .travis.yml
since we don't use Travis and therefore don't maintain this file.
@@ -786,7 +793,7 @@ describe('Change Streams', function() { | |||
} | |||
}); | |||
|
|||
it('Should return MongoNetworkError after first retry attempt fails using promises', { | |||
it.skip('Should return MongoNetworkError after first retry attempt fails using promises', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These twoShould return MongoNetworkError after first retry attempt fails
tests started timing out now that .hasNext
resumes from errors. They just keep resuming from the network errors; none of the resume attempts fail. I'm guessing these tests are quite old and it might make more sense to remove them than to try to fix them.
let server; | ||
let client; | ||
let changeStream; | ||
const oldLabelTest = label => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I just remove these tests for the old labels?
const nextP = changeStream.next(); | ||
|
||
return changeStream.close().then(() => nextP); | ||
const nextP = () => changeStream.next(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change nextP into a function to prevent the .next
from returning successfully before the close
on the next line.
expect(err).to.not.exist; | ||
}); | ||
}, | ||
250 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this small delay because triggering the resumable error immediately after waitForStarted
causes weird behavior, and isn't particularly realistic.
@@ -2800,7 +2815,7 @@ describe('Change Streams', function() { | |||
case 2: | |||
// only events after this point are relevant to this test | |||
events = []; | |||
triggerResumableError(changeStream, () => events.push('error')); | |||
triggerResumableError(changeStream, () => events.push('error'), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, in this case the resumable error needs to be instant because of how the test is constructed; it has to trigger before the next change
event is processed.
I pulled a bunch of changes from this PR that weren't relevant into #2343. I'll open a new PR to replace this one with just the relevant changes, once that one is merged. |
Superseded by #2360. |
Description
NODE-2548
What changed?
getCursor
method to provide fresh cursor after resuming from an errornext
/hasNext
to usegetCursor
processNewChange
maybePromise
workrecreateCursor
to reduce duplication inwaitForTopology
/createChangeStreamCursor
logiccreateChangeStreamCursor
tocreateCursor
ChangeStream.close
to usemaybePromise
Are there any files to ignore?