Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ export class WaitpointSystem {

// Let the worker know immediately, so it can suspend the run
await sendNotificationToWorker({ runId, snapshot, eventBus: this.$.eventBus });

if (isRunBlocked) {
//release concurrency
await this.releaseConcurrencySystem.releaseConcurrencyForSnapshot(snapshot);
}
}

if (timeout) {
Expand All @@ -448,10 +453,7 @@ export class WaitpointSystem {

//no pending waitpoint, schedule unblocking the run
//debounce if we're rapidly adding waitpoints
if (isRunBlocked) {
//release concurrency
await this.releaseConcurrencySystem.releaseConcurrencyForSnapshot(snapshot);
} else {
if (!isRunBlocked) {
await this.$.worker.enqueue({
//this will debounce the call
id: `continueRunIfUnblocked:${runId}`,
Expand Down
21 changes: 21 additions & 0 deletions references/hello-world/src/trigger/release-concurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,24 @@ export const waitReleaseConcurrencyTestTask = task({
};
},
});

export const batchTriggerAndWaitReleaseConcurrency = task({
id: "batch-trigger-and-wait-release-concurrency",
retry: {
maxAttempts: 1,
},
run: async (payload, { ctx }) => {
return await batch.triggerAndWait([
{ id: batchTriggerAndWaitChildTask.id, payload: { waitSeconds: 1 } },
{ id: batchTriggerAndWaitChildTask.id, payload: { waitSeconds: 1 } },
{ id: batchTriggerAndWaitChildTask.id, payload: { waitSeconds: 1 } },
]);
},
});

const batchTriggerAndWaitChildTask = task({
id: "batch-trigger-and-wait-child-task",
run: async (payload: { waitSeconds: number }, { ctx }) => {
await setTimeout(payload.waitSeconds * 1000);
},
});