(error?: Error, wireVersion?: number)
| 1539 | } |
| 1540 | |
| 1541 | export function isResumableError(error?: Error, wireVersion?: number): boolean { |
| 1542 | if (error == null || !(error instanceof MongoError)) { |
| 1543 | return false; |
| 1544 | } |
| 1545 | |
| 1546 | if (error instanceof MongoNetworkError) { |
| 1547 | return true; |
| 1548 | } |
| 1549 | |
| 1550 | if (error instanceof MongoServerSelectionError) { |
| 1551 | return true; |
| 1552 | } |
| 1553 | |
| 1554 | if (wireVersion != null && wireVersion >= 9) { |
| 1555 | // DRIVERS-1308: For 4.4 drivers running against 4.4 servers, drivers will add a special case to treat the CursorNotFound error code as resumable |
| 1556 | if (error.code === MONGODB_ERROR_CODES.CursorNotFound) { |
| 1557 | return true; |
| 1558 | } |
| 1559 | return error.hasErrorLabel(MongoErrorLabel.ResumableChangeStreamError); |
| 1560 | } |
| 1561 | |
| 1562 | if (typeof error.code === 'number') { |
| 1563 | return GET_MORE_RESUMABLE_CODES.has(error.code); |
| 1564 | } |
| 1565 | |
| 1566 | return false; |
| 1567 | } |
no test coverage detected