@hatchet-dev/typescript-sdk 0.1.30 → 0.1.31
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.
|
@@ -17,6 +17,7 @@ export declare class Worker {
|
|
|
17
17
|
contexts: Record<Action['stepRunId'], Context<any, any>>;
|
|
18
18
|
maxRuns?: number;
|
|
19
19
|
logger: Logger;
|
|
20
|
+
registeredWorkflowPromises: Array<Promise<any>>;
|
|
20
21
|
constructor(client: HatchetClient, options: {
|
|
21
22
|
name: string;
|
|
22
23
|
handleKill?: boolean;
|
package/clients/worker/worker.js
CHANGED
|
@@ -31,6 +31,7 @@ class Worker {
|
|
|
31
31
|
constructor(client, options) {
|
|
32
32
|
this.futures = {};
|
|
33
33
|
this.contexts = {};
|
|
34
|
+
this.registeredWorkflowPromises = [];
|
|
34
35
|
this.client = client;
|
|
35
36
|
this.name = this.client.config.namespace + options.name;
|
|
36
37
|
this.action_registry = {};
|
|
@@ -53,7 +54,7 @@ class Worker {
|
|
|
53
54
|
limitStrategy: workflow.concurrency.limitStrategy || workflows_1.ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS,
|
|
54
55
|
}
|
|
55
56
|
: undefined;
|
|
56
|
-
|
|
57
|
+
const registeredWorkflow = this.client.admin.put_workflow({
|
|
57
58
|
name: workflow.id,
|
|
58
59
|
description: workflow.description,
|
|
59
60
|
version: workflow.version || '',
|
|
@@ -82,6 +83,8 @@ class Worker {
|
|
|
82
83
|
},
|
|
83
84
|
],
|
|
84
85
|
});
|
|
86
|
+
this.registeredWorkflowPromises.push(registeredWorkflow);
|
|
87
|
+
yield registeredWorkflow;
|
|
85
88
|
}
|
|
86
89
|
catch (e) {
|
|
87
90
|
throw new hatchet_error_1.default(`Could not register workflow: ${e.message}`);
|
|
@@ -128,7 +131,7 @@ class Worker {
|
|
|
128
131
|
this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
|
|
129
132
|
try {
|
|
130
133
|
// Send the action event to the dispatcher
|
|
131
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, error);
|
|
134
|
+
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, (error === null || error === void 0 ? void 0 : error.message) || error);
|
|
132
135
|
this.client.dispatcher.sendStepActionEvent(event);
|
|
133
136
|
// delete the run from the futures
|
|
134
137
|
delete this.futures[action.stepRunId];
|
|
@@ -273,6 +276,8 @@ class Worker {
|
|
|
273
276
|
start() {
|
|
274
277
|
var _a, e_1, _b, _c;
|
|
275
278
|
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
// ensure all workflows are registered
|
|
280
|
+
yield Promise.all(this.registeredWorkflowPromises);
|
|
276
281
|
try {
|
|
277
282
|
this.listener = yield this.client.dispatcher.getActionListener({
|
|
278
283
|
workerName: this.name,
|