@kb-labs/workflow-daemon 1.6.0 → 2.6.0
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/index.js +24 -16
- package/dist/index.js.map +1 -1
- package/package.json +38 -37
package/dist/index.js
CHANGED
|
@@ -140,7 +140,10 @@ async function createWorkflowWorker(options) {
|
|
|
140
140
|
workspaceId: wsId
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
|
-
|
|
143
|
+
const provisionErr = new Error(`Workspace provisioning failed: ${msg}`);
|
|
144
|
+
await engine.markJobFailed(run.id, job.id, provisionErr);
|
|
145
|
+
claimedJobs.delete(jobKey);
|
|
146
|
+
return true;
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
const jobPromise = (async () => {
|
|
@@ -548,6 +551,9 @@ var JobBroker = class {
|
|
|
548
551
|
this.logger = logger;
|
|
549
552
|
this.platform = platform2;
|
|
550
553
|
}
|
|
554
|
+
engine;
|
|
555
|
+
logger;
|
|
556
|
+
platform;
|
|
551
557
|
/**
|
|
552
558
|
* Submit a background job for execution.
|
|
553
559
|
* Creates a WorkflowSpec with a single job and submits to WorkflowEngine.
|
|
@@ -1178,6 +1184,7 @@ var WorkflowHostService = class {
|
|
|
1178
1184
|
constructor(options) {
|
|
1179
1185
|
this.options = options;
|
|
1180
1186
|
}
|
|
1187
|
+
options;
|
|
1181
1188
|
getHealth() {
|
|
1182
1189
|
return { ok: true, service: "workflow-daemon" };
|
|
1183
1190
|
}
|
|
@@ -1934,7 +1941,9 @@ function registerWorkflowsAPI(options) {
|
|
|
1934
1941
|
raw.flushHeaders?.();
|
|
1935
1942
|
raw.write(": connected\n\n");
|
|
1936
1943
|
const sendEvent = (type, payload) => {
|
|
1937
|
-
if (raw.writableEnded)
|
|
1944
|
+
if (raw.writableEnded) {
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1938
1947
|
raw.write(`event: workflow.event
|
|
1939
1948
|
`);
|
|
1940
1949
|
raw.write(`data: ${JSON.stringify({ type, runId, payload, timestamp: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
@@ -1948,13 +1957,17 @@ function registerWorkflowsAPI(options) {
|
|
|
1948
1957
|
}
|
|
1949
1958
|
let idleTimer = null;
|
|
1950
1959
|
const resetIdle = () => {
|
|
1951
|
-
if (idleTimer)
|
|
1960
|
+
if (idleTimer) {
|
|
1961
|
+
clearTimeout(idleTimer);
|
|
1962
|
+
}
|
|
1952
1963
|
idleTimer = setTimeout(() => {
|
|
1953
1964
|
cleanup();
|
|
1954
1965
|
}, IDLE_TIMEOUT_MS);
|
|
1955
1966
|
};
|
|
1956
1967
|
const keepAliveTimer = setInterval(() => {
|
|
1957
|
-
if (raw.writableEnded)
|
|
1968
|
+
if (raw.writableEnded) {
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1958
1971
|
raw.write(": keep-alive\n\n");
|
|
1959
1972
|
}, KEEP_ALIVE_MS);
|
|
1960
1973
|
const unsubscribe = engine.subscribeToRunEvents(runId, (event) => {
|
|
@@ -1966,9 +1979,13 @@ function registerWorkflowsAPI(options) {
|
|
|
1966
1979
|
});
|
|
1967
1980
|
const cleanup = () => {
|
|
1968
1981
|
unsubscribe();
|
|
1969
|
-
if (idleTimer)
|
|
1982
|
+
if (idleTimer) {
|
|
1983
|
+
clearTimeout(idleTimer);
|
|
1984
|
+
}
|
|
1970
1985
|
clearInterval(keepAliveTimer);
|
|
1971
|
-
if (!raw.writableEnded)
|
|
1986
|
+
if (!raw.writableEnded) {
|
|
1987
|
+
raw.end();
|
|
1988
|
+
}
|
|
1972
1989
|
};
|
|
1973
1990
|
resetIdle();
|
|
1974
1991
|
request.raw.on("close", cleanup);
|
|
@@ -2405,19 +2422,10 @@ async function bootstrap(cwd = process.cwd()) {
|
|
|
2405
2422
|
});
|
|
2406
2423
|
bootstrapLogger.info("Loading plugin registry snapshot");
|
|
2407
2424
|
const cliApi = await createRegistry({
|
|
2408
|
-
|
|
2409
|
-
root: repoRoot
|
|
2410
|
-
},
|
|
2425
|
+
root: repoRoot,
|
|
2411
2426
|
cache: {
|
|
2412
|
-
inMemory: true,
|
|
2413
2427
|
ttlMs: 10 * 60 * 1e3
|
|
2414
2428
|
// 10 minutes
|
|
2415
|
-
},
|
|
2416
|
-
logger: {
|
|
2417
|
-
level: "info"
|
|
2418
|
-
},
|
|
2419
|
-
snapshot: {
|
|
2420
|
-
mode: "consumer"
|
|
2421
2429
|
}
|
|
2422
2430
|
});
|
|
2423
2431
|
await cliApi.initialize();
|