blob: 719395d42f5180f0b7d3b2e75e8ce6a2ecd4081a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/**
* Utilities for testing when sessions are killed.
*/
var KilledSessionUtil = (function() {
// Returns if the code is one that could come from a session being killed.
function isKilledSessionCode(code) {
return code === ErrorCodes.Interrupted || code === ErrorCodes.CursorKilled ||
code === ErrorCodes.CursorNotFound || code === ErrorCodes.QueryPlanKilled;
}
function hasKilledSessionError(errOrRes) {
return isKilledSessionCode(errOrRes.code) ||
(Array.isArray(errOrRes.writeErrors) &&
errOrRes.writeErrors.every(writeError => isKilledSessionCode(writeError.code)));
}
function hasKilledSessionWCError(res) {
return res.writeConcernError && isKilledSessionCode(res.writeConcernError.code);
}
return {
isKilledSessionCode,
hasKilledSessionError,
hasKilledSessionWCError,
};
})();
|