Skip to content

Commit

Permalink
0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pilsy committed Sep 21, 2024
1 parent 44240a5 commit ef0470f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chrono-forge",
"version": "0.9.1",
"version": "0.9.3",
"description": "A comprehensive framework for building resilient Temporal workflows, advanced state management, and real-time streaming activities in TypeScript. Designed for a seamless developer experience with powerful abstractions, dynamic orchestration, and full control over distributed systems.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/SchemaManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class SchemaManager extends EventEmitter {
if (!isEmpty(differences.added) || !isEmpty(differences.updated) || !isEmpty(differences.deleted)) {
this.pushToHistory(previousState);
this.future.length = 0;
this.state = { ...newState };
this.state = newState;

this.invalidateCache(differences);

Expand Down
38 changes: 15 additions & 23 deletions src/workflows/StatefulWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { SchemaManager } from '../SchemaManager';
import { limitRecursion } from '../utils/limitRecursion';
import { getCompositeKey } from '../utils/getCompositeKey';
import { PROPERTY_METADATA_KEY } from '../decorators';
import { UpdateHandlerOptions } from '@temporalio/workflow/lib/interfaces';
import { UpdateHandlerOptions, Handler } from '@temporalio/workflow/lib/interfaces';
import { setWithProxy } from '../utils';
import { HandlerUnfinishedPolicy } from '@temporalio/common';

export type ManagedPath = {
entityName?: string;
Expand Down Expand Up @@ -152,8 +153,6 @@ export abstract class StatefulWorkflow<
return this.schemaManager.pendingChanges;
}

protected actionHandlers: Record<string, Function> = {};

@Property({ set: false })
protected subscriptions: Subscription[] = [];

Expand Down Expand Up @@ -890,32 +889,25 @@ export abstract class StatefulWorkflow<
if (validatorMethod) {
updateOptions.validator = (this as any)[validatorMethod].bind(this);
}
updateOptions.unfinishedPolicy = HandlerUnfinishedPolicy.ABANDON;

workflow.setHandler(
workflow.defineUpdate<any, any>(method),
async (input: any): Promise<any> => {
this._actionRunning = true;
return await new Promise(async (resolve, reject) => {
let result: any;
let error: any;
try {
result = await (this[methodName] as (input: any) => any)(input);
} catch (err: any) {
error = err;
} finally {
this._actionRunning = false;
}
let result: any;
let error: any;
try {
result = await (this[methodName] as (input: any) => any)(input);
} catch (err: any) {
error = err;
this.log.error(error);
} finally {
this._actionRunning = false;
}

Promise.resolve().then(async () => {
if (!error) {
await workflow.condition(() => !this.schemaManager.processing);
resolve(result ? result : this.data);
} else {
this.log.error(error);
reject(error);
}
});
});
await workflow.condition(() => !this.schemaManager.processing);
return result !== undefined ? result : this.data;
},
updateOptions
);
Expand Down

0 comments on commit ef0470f

Please sign in to comment.