From 4e42beecc6ade8743dd26dccad50ecf0da183280 Mon Sep 17 00:00:00 2001 From: Gabe Ruttner Date: Fri, 18 Apr 2025 10:54:22 -0400 Subject: [PATCH] fix: serial-registration (#1574) * fix: serial-registration * fix case * release ver --- sdks/typescript/package.json | 2 +- sdks/typescript/src/v1/client/worker.ts | 34 +++++++++++-------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/sdks/typescript/package.json b/sdks/typescript/package.json index 7ed65742f..db04ab1ea 100644 --- a/sdks/typescript/package.json +++ b/sdks/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@hatchet-dev/typescript-sdk", - "version": "1.3.1", + "version": "1.3.2", "description": "Background task orchestration & visibility for developers", "types": "dist/index.d.ts", "files": [ diff --git a/sdks/typescript/src/v1/client/worker.ts b/sdks/typescript/src/v1/client/worker.ts index 60247fa6d..57382e367 100644 --- a/sdks/typescript/src/v1/client/worker.ts +++ b/sdks/typescript/src/v1/client/worker.ts @@ -87,29 +87,25 @@ export class Worker { * @returns Array of registered workflow promises */ async registerWorkflows(workflows?: Array | V0Workflow>) { - return Promise.all( - workflows?.map(async (wf) => { - if (wf instanceof BaseWorkflowDeclaration) { - // TODO check if tenant is V1 - const register = this.nonDurable.registerWorkflowV1(wf); + for (const wf of workflows || []) { + if (wf instanceof BaseWorkflowDeclaration) { + // TODO check if tenant is V1 + await this.nonDurable.registerWorkflowV1(wf); - if (wf.definition._durableTasks.length > 0) { - if (!this.durable) { - this.durable = await this._v0.worker(`${this.name}-durable`, { - ...this.config, - maxRuns: this.config.durableSlots || DEFAULT_DURABLE_SLOTS, - }); - } - this.durable.registerDurableActionsV1(wf.definition); + if (wf.definition._durableTasks.length > 0) { + if (!this.durable) { + this.durable = await this._v0.worker(`${this.name}-durable`, { + ...this.config, + maxRuns: this.config.durableSlots || DEFAULT_DURABLE_SLOTS, + }); } - - return register; + this.durable.registerDurableActionsV1(wf.definition); } - + } else { // fallback to v0 client for backwards compatibility - return this.nonDurable.registerWorkflow(wf); - }) || [] - ); + await this.nonDurable.registerWorkflow(wf); + } + } } /**