(error: MongoError)
| 1452 | |
| 1453 | /** Determines whether an error is something the driver should attempt to retry */ |
| 1454 | export function isRetryableReadError(error: MongoError): boolean { |
| 1455 | const hasRetryableErrorCode = |
| 1456 | typeof error.code === 'number' ? RETRYABLE_READ_ERROR_CODES.has(error.code) : false; |
| 1457 | if (hasRetryableErrorCode) { |
| 1458 | return true; |
| 1459 | } |
| 1460 | |
| 1461 | if (error instanceof MongoNetworkError) { |
| 1462 | return true; |
| 1463 | } |
| 1464 | |
| 1465 | const isNotWritablePrimaryError = LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE.test(error.message); |
| 1466 | if (isNotWritablePrimaryError) { |
| 1467 | return true; |
| 1468 | } |
| 1469 | |
| 1470 | const isNodeIsRecoveringError = NODE_IS_RECOVERING_ERROR_MESSAGE.test(error.message); |
| 1471 | if (isNodeIsRecoveringError) { |
| 1472 | return true; |
| 1473 | } |
| 1474 | |
| 1475 | return false; |
| 1476 | } |
| 1477 | |
| 1478 | const SDAM_RECOVERING_CODES = new Set<number>([ |
| 1479 | MONGODB_ERROR_CODES.ShutdownInProgress, |
no test coverage detected