Skip to content

Commit 3dc2db6

Browse files
committed
add runtime orchestration
Signed-off-by: yaron2 <schneider.yaron@live.com>
1 parent f368bd7 commit 3dc2db6

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/worker/runtime-orchestration-context.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,20 @@ export class RuntimeOrchestrationContext extends OrchestrationContext {
9999
if (this._previousTask.isFailed) {
100100
// Raise the failure as an exception to the generator. The orchestrator can then either
101101
// handle the exception or allow it to fail the orchestration.
102-
await this._generator.throw(this._previousTask._exception);
103-
} else if (this._previousTask.isComplete) {
102+
const { done, value } = await this._generator.throw(this._previousTask._exception);
103+
if (done) {
104+
throw new StopIterationError(value);
105+
}
106+
if (!(value instanceof Task)) {
107+
throw new Error("The orchestrator generator yielded a non-Task object");
108+
}
109+
this._previousTask = value;
110+
// If the new task is already complete, fall through to the isComplete handler
111+
if (!this._previousTask.isComplete) {
112+
return;
113+
}
114+
}
115+
if (this._previousTask.isComplete) {
104116
while (true) {
105117
// Resume the generator. This will either return a Task or raise StopIteration if it's done.
106118
// @todo: Should we check for possible infinite loops here?

0 commit comments

Comments
 (0)