Skip to content

Commit 2a0e50f

Browse files
authored
Update mutex to use workflowInfo().continueAsNewSuggested (#342)
1 parent 5fac519 commit 2a0e50f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mutex/src/workflows.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const { signalWithStartLockWorkflow, useAPIThatCantBeCalledInParallel, notifyLoc
1717
startToCloseTimeout: '1 minute',
1818
});
1919

20-
const MAX_WORKFLOW_HISTORY_LENGTH = 2000;
21-
2220
interface LockResponse {
2321
releaseSignalName: string;
2422
}
@@ -29,10 +27,12 @@ export async function lockWorkflow(requests = Array<LockRequest>()): Promise<voi
2927
requests.push(req);
3028
});
3129
setHandler(currentWorkflowIdQuery, () => currentWorkflowId);
32-
while (workflowInfo().historyLength < MAX_WORKFLOW_HISTORY_LENGTH) {
30+
31+
// Run workflow until workflowInfo suggests to continue as new
32+
while (!workflowInfo().continueAsNewSuggested) {
3333
await condition(() => requests.length > 0);
3434
const req = requests.shift();
35-
// Check for `undefined` because otherwise TypeScript complans that `req`
35+
// Check for `undefined` because otherwise TypeScript complains that `req`
3636
// may be undefined.
3737
if (req === undefined) {
3838
continue;

0 commit comments

Comments
 (0)