12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- 'use strict';
- const MongoNetworkError = require('mongodb-core').MongoNetworkError;
- const mongoErrorContextSymbol = require('mongodb-core').mongoErrorContextSymbol;
- const GET_MORE_NON_RESUMABLE_CODES = new Set([
- 136,
- 237,
- 11601
- ]);
- function isGetMoreError(error) {
- if (error[mongoErrorContextSymbol]) {
- return error[mongoErrorContextSymbol].isGetMore;
- }
- }
- function isResumableError(error) {
- if (!isGetMoreError(error)) {
- return false;
- }
- return !!(
- error instanceof MongoNetworkError ||
- !GET_MORE_NON_RESUMABLE_CODES.has(error.code) ||
- error.message.match(/not master/) ||
- error.message.match(/node is recovering/)
- );
- }
- module.exports = { GET_MORE_NON_RESUMABLE_CODES, isResumableError };
|