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
1 change: 1 addition & 0 deletions packages/durabletask-js/src/testing/in-memory-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ export class InMemoryOrchestrationBackend {
instance.history = [];
instance.input = newInput;
instance.output = undefined;
instance.customStatus = undefined;
instance.failureDetails = undefined;
instance.status = pb.OrchestrationStatus.ORCHESTRATION_STATUS_PENDING;

Expand Down
26 changes: 26 additions & 0 deletions packages/durabletask-js/test/in-memory-backend.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,32 @@ describe("In-Memory Backend", () => {
expect(state?.serializedOutput).toEqual(JSON.stringify(5));
});

it("should clear customStatus after continue-as-new", async () => {
const orchestrator: TOrchestrator = async (ctx: OrchestrationContext, input: number) => {
if (input === 1) {
// First iteration: set a custom status then continue-as-new
ctx.setCustomStatus("iteration-1-status");
ctx.continueAsNew(2, false);
} else {
// Second iteration: do NOT set custom status — it should be cleared
return "done";
}
};

worker.addOrchestrator(orchestrator);
await worker.start();

const id = await client.scheduleNewOrchestration(orchestrator, 1);
const state = await client.waitForOrchestrationCompletion(id, true, 10);

expect(state).toBeDefined();
expect(state?.runtimeStatus).toEqual(OrchestrationStatus.COMPLETED);
expect(state?.serializedOutput).toEqual(JSON.stringify("done"));
// customStatus must be cleared after continue-as-new when the new iteration
// does not set one — it should not carry over from the previous iteration
expect(state?.serializedCustomStatus).toBeUndefined();
});

it("should preserve sendEvent actions when continuing-as-new", async () => {
// Receiver orchestration that waits for an event
const receiver: TOrchestrator = async function* (ctx: OrchestrationContext): any {
Expand Down
Loading