Skip to content

Commit 7cf669d

Browse files
authored
fix: remove check for NonResumableChangeStreamError label
The isResumableError function should not check for the NonResumableChangeStreamError label. NODE-2565
1 parent bee0aa2 commit 7cf669d

File tree

3 files changed

+4
-41
lines changed

3 files changed

+4
-41
lines changed

lib/cursor/core_cursor.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { collationNotSupported, SUPPORTS, MongoDBNamespace } = require('../utils'
66
const executeOperation = require('../operations/execute_operation');
77
const { Readable } = require('stream');
88
const { OperationBase } = require('../operations/operation');
9-
const { MongoError, MongoNetworkError, mongoErrorContextSymbol } = require('../error');
9+
const { MongoError, MongoNetworkError } = require('../error');
1010
const {
1111
BSON: { Long }
1212
} = require('../deps');
@@ -793,10 +793,6 @@ function nextFunction(self, callback) {
793793
// Execute the next get more
794794
self._getMore(function(err, doc, connection) {
795795
if (err) {
796-
if (err instanceof MongoError) {
797-
err[mongoErrorContextSymbol].isGetMore = true;
798-
}
799-
800796
return handleCallback(callback, err);
801797
}
802798

lib/error.js

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
'use strict';
22

3-
const mongoErrorContextSymbol = Symbol('mongoErrorContextSymbol');
43
const kErrorLabels = Symbol('errorLabels');
5-
const GET_MORE_NON_RESUMABLE_CODES = new Set([
6-
136, // CappedPositionLost
7-
237, // CursorKilled
8-
11601 // Interrupted
9-
]);
4+
105
// From spec@https://github.com/mongodb/specifications/blob/f93d78191f3db2898a59013a7ed5650352ef6da8/source/change-streams/change-streams.rst#resumable-error
116
const GET_MORE_RESUMABLE_CODES = new Set([
127
6, // HostUnreachable
@@ -60,7 +55,6 @@ class MongoError extends Error {
6055
}
6156

6257
this.name = 'MongoError';
63-
this[mongoErrorContextSymbol] = this[mongoErrorContextSymbol] || {};
6458
}
6559

6660
/**
@@ -343,17 +337,7 @@ function isNetworkTimeoutError(err) {
343337
//
344338
// An error on an aggregate command is not a resumable error. Only errors on a getMore command may be considered resumable errors.
345339

346-
function isGetMoreError(error) {
347-
if (error[mongoErrorContextSymbol]) {
348-
return error[mongoErrorContextSymbol].isGetMore;
349-
}
350-
}
351-
352340
function isResumableError(error, wireVersion) {
353-
if (!isGetMoreError(error)) {
354-
return false;
355-
}
356-
357341
if (error instanceof MongoNetworkError) {
358342
return true;
359343
}
@@ -362,22 +346,17 @@ function isResumableError(error, wireVersion) {
362346
return error.hasErrorLabel('ResumableChangeStreamError');
363347
}
364348

365-
return (
366-
GET_MORE_RESUMABLE_CODES.has(error.code) &&
367-
!error.hasErrorLabel('NonResumableChangeStreamError')
368-
);
349+
return GET_MORE_RESUMABLE_CODES.has(error.code);
369350
}
370351

371352
module.exports = {
372-
GET_MORE_NON_RESUMABLE_CODES,
373353
GET_MORE_RESUMABLE_CODES,
374354
MongoError,
375355
MongoNetworkError,
376356
MongoParseError,
377357
MongoTimeoutError,
378358
MongoServerSelectionError,
379359
MongoWriteConcernError,
380-
mongoErrorContextSymbol,
381360
isRetryableError,
382361
isSDAMUnrecoverableError,
383362
isNodeShuttingDownError,

test/functional/change_stream.test.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
'use strict';
22
const assert = require('assert');
33
const { Transform } = require('stream');
4-
const {
5-
MongoError,
6-
MongoNetworkError,
7-
mongoErrorContextSymbol,
8-
isResumableError
9-
} = require('../../lib/error');
4+
const { MongoError, MongoNetworkError } = require('../../lib/error');
105
const { setupDatabase, delay } = require('./shared');
116
const co = require('co');
127
const mock = require('mongodb-mock-server');
@@ -31,7 +26,6 @@ function triggerResumableError(changeStream, onCursorClosed) {
3126
changeStream.cursor.close(callback);
3227
};
3328
const fakeResumableError = new MongoNetworkError('fake error');
34-
fakeResumableError[mongoErrorContextSymbol] = { isGetMore: true };
3529
changeStream.cursor.emit('error', fakeResumableError);
3630
}
3731

@@ -2798,9 +2792,3 @@ describe('Change Streams', function() {
27982792
});
27992793
});
28002794
});
2801-
2802-
describe('Change Stream Resume Error Tests', function() {
2803-
it('should properly process errors that lack the `mongoErrorContextSymbol`', function() {
2804-
expect(() => isResumableError(new Error())).to.not.throw();
2805-
});
2806-
});

0 commit comments

Comments
 (0)