patchrelay 0.8.8 → 0.8.9
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.
- package/dist/build-info.json +3 -3
- package/dist/service-runtime.js +17 -1
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
package/dist/service-runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SerialWorkQueue } from "./service-queue.js";
|
|
2
2
|
const ISSUE_KEY_DELIMITER = "::";
|
|
3
3
|
const DEFAULT_RECONCILE_INTERVAL_MS = 5_000;
|
|
4
|
+
const DEFAULT_RECONCILE_TIMEOUT_MS = 60_000;
|
|
4
5
|
function toReconciler(value) {
|
|
5
6
|
if (typeof value === "function") {
|
|
6
7
|
return {
|
|
@@ -124,7 +125,7 @@ export class ServiceRuntime {
|
|
|
124
125
|
}
|
|
125
126
|
this.reconcileInProgress = true;
|
|
126
127
|
try {
|
|
127
|
-
await this.stageRunReconciler.reconcileActiveStageRuns();
|
|
128
|
+
await promiseWithTimeout(this.stageRunReconciler.reconcileActiveStageRuns(), this.options.reconcileTimeoutMs ?? DEFAULT_RECONCILE_TIMEOUT_MS, "Background active-stage reconciliation");
|
|
128
129
|
}
|
|
129
130
|
catch (error) {
|
|
130
131
|
this.logger.warn({
|
|
@@ -139,3 +140,18 @@ export class ServiceRuntime {
|
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
}
|
|
143
|
+
function promiseWithTimeout(promise, timeoutMs, label) {
|
|
144
|
+
return new Promise((resolve, reject) => {
|
|
145
|
+
const timeout = setTimeout(() => {
|
|
146
|
+
reject(new Error(`${label} timed out after ${timeoutMs}ms`));
|
|
147
|
+
}, timeoutMs);
|
|
148
|
+
timeout.unref?.();
|
|
149
|
+
promise.then((value) => {
|
|
150
|
+
clearTimeout(timeout);
|
|
151
|
+
resolve(value);
|
|
152
|
+
}, (error) => {
|
|
153
|
+
clearTimeout(timeout);
|
|
154
|
+
reject(error);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|