@@ -22,6 +22,7 @@ import { FailedTaskRunService } from "../failedTaskRun.server";
2222import { CancelDevSessionRunsService } from "../services/cancelDevSessionRuns.server" ;
2323import { CompleteAttemptService } from "../services/completeAttempt.server" ;
2424import { attributesFromAuthenticatedEnv , tracer } from "../tracer.server" ;
25+ import { compareDeploymentVersions } from "../utils/deploymentVersions" ;
2526import { DevSubscriber , devPubSub } from "./devPubSub.server" ;
2627
2728const MessageBody = z . discriminatedUnion ( "type" , [
@@ -589,7 +590,7 @@ export class DevQueueConsumer {
589590 }
590591
591592 // Get the latest background worker based on the version.
592- // Versions are in the format of 20240101.1 and 20240101.2, or even 20240101.10 , 20240101.11, etc.
593+ // Versions are in the format of YYYYMMDD.N (e.g., 20240101.1) with optional suffix (e.g. , 20240101.1-hardened)
593594 #getLatestBackgroundWorker( ) {
594595 const workers = Array . from ( this . _backgroundWorkers . values ( ) ) ;
595596
@@ -598,22 +599,10 @@ export class DevQueueConsumer {
598599 }
599600
600601 return workers . reduce ( ( acc , curr ) => {
601- const accParts = acc . version . split ( "." ) . map ( Number ) ;
602- const currParts = curr . version . split ( "." ) . map ( Number ) ;
603-
604- // Compare the major part
605- if ( accParts [ 0 ] < currParts [ 0 ] ) {
606- return curr ;
607- } else if ( accParts [ 0 ] > currParts [ 0 ] ) {
608- return acc ;
609- }
610-
611- // Compare the minor part (assuming all versions have two parts)
612- if ( accParts [ 1 ] < currParts [ 1 ] ) {
613- return curr ;
614- } else {
615- return acc ;
616- }
602+ // Use compareDeploymentVersions to properly handle versions with suffixes
603+ const comparison = compareDeploymentVersions ( acc . version , curr . version ) ;
604+ // If curr is newer (comparison returns -1), use curr, otherwise use acc
605+ return comparison < 0 ? curr : acc ;
617606 } ) ;
618607 }
619608}
0 commit comments