From f1900723768dcfef0ecfa8b8d323cc21df8179aa Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 12 Jul 2019 12:34:54 -0400 Subject: [PATCH] fix(change-streams): don't copy irrelevant resume options --- lib/change_stream.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/change_stream.js b/lib/change_stream.js index c9162db3b3..59bbc882e9 100644 --- a/lib/change_stream.js +++ b/lib/change_stream.js @@ -272,10 +272,14 @@ class ChangeStreamCursor extends Cursor { if (this.options[optionName]) result[optionName] = this.options[optionName]; } - if (this.resumeToken) { - Object.assign(result, { resumeAfter: this.resumeToken }); - } else if (this.startAtOperationTime && maxWireVersion(this.server) >= 7) { - Object.assign(result, { startAtOperationTime: this.startAtOperationTime }); + if (this.resumeToken || this.startAtOperationTime) { + ['resumeAfter', 'startAfter', 'startAtOperationTime'].forEach(key => delete result[key]); + + if (this.resumeToken) { + result.resumeAfter = this.resumeToken; + } else if (this.startAtOperationTime && maxWireVersion(this.server) >= 7) { + result.startAtOperationTime = this.startAtOperationTime; + } } return result;