@@ -299,6 +299,8 @@ async Task OnRunOrchestratorAsync(
299299 ? new ( this . internalOptions . InsertEntityUnlocksOnCompletion )
300300 : null ;
301301
302+ DurableTaskWorkerOptions . VersioningOptions ? versioning = this . worker . workerOptions . Versioning ;
303+ bool versionFailure = false ;
302304 try
303305 {
304306 OrchestrationRuntimeState runtimeState = await this . BuildRuntimeStateAsync (
@@ -308,11 +310,11 @@ async Task OnRunOrchestratorAsync(
308310
309311
310312 // If versioning has been explicitly set, we attempt to follow that pattern. If it is not set, we don't compare versions here.
311- if ( this . worker . workerOptions . IsVersioningSet )
313+ if ( versioning != null )
312314 {
313- int versionComparison = TaskOrchestrationVersioningUtils . CompareVersions ( runtimeState . Version , this . worker . workerOptions . Versioning . Version ) ;
315+ int versionComparison = TaskOrchestrationVersioningUtils . CompareVersions ( runtimeState . Version , versioning . Version ) ;
314316
315- switch ( this . worker . workerOptions . Versioning . MatchStrategy )
317+ switch ( versioning . MatchStrategy )
316318 {
317319 case DurableTaskWorkerOptions . VersionMatchStrategy . None :
318320 // No versioning, breakout.
@@ -324,7 +326,7 @@ async Task OnRunOrchestratorAsync(
324326 failureDetails = new P . TaskFailureDetails
325327 {
326328 ErrorType = "VersionMismatch" ,
327- ErrorMessage = $ "The orchestration version '{ runtimeState . Version } ' does not match the worker version '{ this . worker . grpcOptions . Versioning . Version } '.",
329+ ErrorMessage = $ "The orchestration version '{ runtimeState . Version } ' does not match the worker version '{ versioning . Version } '.",
328330 IsNonRetriable = true ,
329331 } ;
330332 }
@@ -337,7 +339,7 @@ async Task OnRunOrchestratorAsync(
337339 failureDetails = new P . TaskFailureDetails
338340 {
339341 ErrorType = "VersionMismatch" ,
340- ErrorMessage = $ "The orchestration version '{ runtimeState . Version } ' is greater than the worker version '{ this . worker . grpcOptions . Versioning . Version } '.",
342+ ErrorMessage = $ "The orchestration version '{ runtimeState . Version } ' is greater than the worker version '{ versioning . Version } '.",
341343 IsNonRetriable = true ,
342344 } ;
343345 }
@@ -348,11 +350,13 @@ async Task OnRunOrchestratorAsync(
348350 failureDetails = new P . TaskFailureDetails
349351 {
350352 ErrorType = "VersionError" ,
351- ErrorMessage = $ "The version match strategy '{ this . worker . workerOptions . Versioning . MatchStrategy } ' is unknown.",
353+ ErrorMessage = $ "The version match strategy '{ versioning . MatchStrategy } ' is unknown.",
352354 IsNonRetriable = true ,
353355 } ;
354356 break ;
355357 }
358+
359+ versionFailure = failureDetails != null ;
356360 }
357361
358362 // Only continue with the work if the versioning check passed.
@@ -415,9 +419,9 @@ async Task OnRunOrchestratorAsync(
415419 completionToken ,
416420 entityConversionState ) ;
417421 }
418- else if ( failureDetails != null && failureDetails . ErrorType == "VersionMismatch" )
422+ else if ( versioning != null && failureDetails != null && versionFailure )
419423 {
420- if ( this . worker . workerOptions . Versioning . FailureStrategy == DurableTaskWorkerOptions . VersionFailureStrategy . Fail )
424+ if ( versioning . FailureStrategy == DurableTaskWorkerOptions . VersionFailureStrategy . Fail )
421425 {
422426 response = new P . OrchestratorResponse
423427 {
@@ -436,17 +440,6 @@ async Task OnRunOrchestratorAsync(
436440 } ,
437441 } ;
438442 }
439- else if ( this . worker . workerOptions . Versioning . FailureStrategy == DurableTaskWorkerOptions . VersionFailureStrategy . Suspend )
440- {
441- await this . client . SuspendInstanceAsync (
442- new P . SuspendRequest
443- {
444- InstanceId = request . InstanceId ,
445- Reason = "Version mismatch" ,
446- } ,
447- cancellationToken : cancellationToken ) ;
448- return ;
449- }
450443 else
451444 {
452445 await this . client . AbandonTaskOrchestratorWorkItemAsync (
0 commit comments