Skip to content

Commit 933f78a

Browse files
authored
fix: clear customStatus on continue-as-new in InMemoryOrchestrationBackend (#155)
1 parent 40f249b commit 933f78a

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

packages/durabletask-js/src/testing/in-memory-backend.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ export class InMemoryOrchestrationBackend {
481481
instance.history = [];
482482
instance.input = newInput;
483483
instance.output = undefined;
484+
instance.customStatus = undefined;
484485
instance.failureDetails = undefined;
485486
instance.status = pb.OrchestrationStatus.ORCHESTRATION_STATUS_PENDING;
486487

packages/durabletask-js/test/in-memory-backend.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,32 @@ describe("In-Memory Backend", () => {
229229
expect(state?.serializedOutput).toEqual(JSON.stringify(5));
230230
});
231231

232+
it("should clear customStatus after continue-as-new", async () => {
233+
const orchestrator: TOrchestrator = async (ctx: OrchestrationContext, input: number) => {
234+
if (input === 1) {
235+
// First iteration: set a custom status then continue-as-new
236+
ctx.setCustomStatus("iteration-1-status");
237+
ctx.continueAsNew(2, false);
238+
} else {
239+
// Second iteration: do NOT set custom status — it should be cleared
240+
return "done";
241+
}
242+
};
243+
244+
worker.addOrchestrator(orchestrator);
245+
await worker.start();
246+
247+
const id = await client.scheduleNewOrchestration(orchestrator, 1);
248+
const state = await client.waitForOrchestrationCompletion(id, true, 10);
249+
250+
expect(state).toBeDefined();
251+
expect(state?.runtimeStatus).toEqual(OrchestrationStatus.COMPLETED);
252+
expect(state?.serializedOutput).toEqual(JSON.stringify("done"));
253+
// customStatus must be cleared after continue-as-new when the new iteration
254+
// does not set one — it should not carry over from the previous iteration
255+
expect(state?.serializedCustomStatus).toBeUndefined();
256+
});
257+
232258
it("should preserve sendEvent actions when continuing-as-new", async () => {
233259
// Receiver orchestration that waits for an event
234260
const receiver: TOrchestrator = async function* (ctx: OrchestrationContext): any {

0 commit comments

Comments
 (0)