@@ -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