@koralabs/kora-labs-common 6.19.0 → 6.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,11 @@ export declare const leaseMs: (override?: number) => number;
34
34
  export declare const parseOffline: (raw: string | undefined | null) => string[];
35
35
  type Mode = 'serial' | 'localSerial' | 'standDown';
36
36
  export declare const resolveMode: (offline: string[], topology: CronLockTopology) => Mode;
37
- /** Only an UNAVAILABLE response proves that no SERIAL proposal was accepted. */
37
+ /**
38
+ * Only an UNAVAILABLE response proves that no SERIAL proposal was accepted. The driver's default retry
39
+ * policy retries UNAVAILABLE on the next host and then throws NoHostAvailableError wrapping each host's
40
+ * error, so that counts only when every host tried answered UNAVAILABLE.
41
+ */
38
42
  export declare const isPeerUnavailableError: (error: unknown) => boolean;
39
43
  /** A write timeout leaves an LWT's outcome unknown: the proposal may or may not have been applied. */
40
44
  export declare const isWriteTimeoutError: (error: unknown) => boolean;
@@ -119,8 +119,19 @@ const resolveMode = (offline, topology) => {
119
119
  };
120
120
  exports.resolveMode = resolveMode;
121
121
  const createToken = (topology) => `${topology.nodeCode}:${(0, node_crypto_1.randomUUID)()}`;
122
- /** Only an UNAVAILABLE response proves that no SERIAL proposal was accepted. */
123
- const isPeerUnavailableError = (error) => error instanceof cassandra_driver_1.errors.ResponseError && error.code === cassandra_driver_1.types.responseErrorCodes.unavailableException;
122
+ /**
123
+ * Only an UNAVAILABLE response proves that no SERIAL proposal was accepted. The driver's default retry
124
+ * policy retries UNAVAILABLE on the next host and then throws NoHostAvailableError wrapping each host's
125
+ * error, so that counts only when every host tried answered UNAVAILABLE.
126
+ */
127
+ const isPeerUnavailableError = (error) => {
128
+ var _a;
129
+ if (error instanceof cassandra_driver_1.errors.NoHostAvailableError) {
130
+ const inner = Object.values((_a = error.innerErrors) !== null && _a !== void 0 ? _a : {});
131
+ return inner.length > 0 && inner.every(exports.isPeerUnavailableError);
132
+ }
133
+ return error instanceof cassandra_driver_1.errors.ResponseError && error.code === cassandra_driver_1.types.responseErrorCodes.unavailableException;
134
+ };
124
135
  exports.isPeerUnavailableError = isPeerUnavailableError;
125
136
  /** A write timeout leaves an LWT's outcome unknown: the proposal may or may not have been applied. */
126
137
  const isWriteTimeoutError = (error) => error instanceof cassandra_driver_1.errors.ResponseError && error.code === cassandra_driver_1.types.responseErrorCodes.writeTimeout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "6.19.0",
3
+ "version": "6.19.2",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -53,7 +53,7 @@
53
53
  "eslint": "^8.57.1",
54
54
  "jest": "^30.4.2",
55
55
  "scalus": "^0.15.0",
56
- "ts-jest": "^29.4.11",
56
+ "ts-jest": "^29.4.14",
57
57
  "typescript": "^5.9.3"
58
58
  },
59
59
  "dependencies": {
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "overrides": {
72
72
  "js-yaml": "4.3.2",
73
- "brace-expansion": "5.0.9"
73
+ "brace-expansion": "5.0.12"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@aiken-lang/merkle-patricia-forestry": "^1.2.0",