@@ -26,6 +26,7 @@ import * as ServerSelfUpdate from "./selfUpdate.ts";
2626interface HarnessOptions {
2727 readonly mode ?: "web" | "desktop" ;
2828 readonly managed ?: boolean ;
29+ readonly launcherProtocol ?: 3 | typeof SERVICE_LAUNCHER_PROTOCOL ;
2930 readonly preflight ?: "ready" | "blocked" ;
3031 readonly preflightDuration ?: Duration . Input ;
3132 readonly preflightStarted ?: Deferred . Deferred < void > ;
@@ -65,6 +66,7 @@ const makeHarness = Effect.fn("test.make_self_update_harness")(function* (
6566 const baseDir = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-self-update-test-" } ) ;
6667 const order : string [ ] = [ ] ;
6768 const urls : string [ ] = [ ] ;
69+ const preflightProtocols : Array < string | undefined > = [ ] ;
6870 const runner = ProcessRunner . ProcessRunner . of ( {
6971 run : ( input ) =>
7072 Effect . gen ( function * ( ) {
@@ -113,14 +115,13 @@ const makeHarness = Effect.fn("test.make_self_update_harness")(function* (
113115 }
114116 }
115117 order . push ( "preflight" ) ;
118+ // Like a release, report back the launcher protocol the server named.
119+ const named = input . args [ input . args . indexOf ( "--launcher-protocol" ) + 1 ] ;
120+ preflightProtocols . push ( named ) ;
116121 const result =
117122 options . preflight === "blocked"
118123 ? { status : "blocked" , version : "1.1.0" , reason : "local update required" }
119- : {
120- status : "ready" ,
121- version : "1.1.0" ,
122- launcherProtocol : SERVICE_LAUNCHER_PROTOCOL ,
123- } ;
124+ : { status : "ready" , version : "1.1.0" , launcherProtocol : Number ( named ) } ;
124125 return {
125126 stdout : JSON . stringify ( result ) ,
126127 stderr : "" ,
@@ -133,8 +134,10 @@ const makeHarness = Effect.fn("test.make_self_update_harness")(function* (
133134 } ;
134135 } ) ,
135136 } ) ;
137+ const managed = options . managed ?? true ;
136138 const launcher = ServiceLauncherClient . ServiceLauncherClient . of ( {
137- managed : options . managed ?? true ,
139+ managed,
140+ protocol : managed ? ( options . launcherProtocol ?? SERVICE_LAUNCHER_PROTOCOL ) : undefined ,
138141 requestUpdate :
139142 options . requestUpdate ??
140143 ( ( ) =>
@@ -170,7 +173,7 @@ const makeHarness = Effect.fn("test.make_self_update_harness")(function* (
170173 ) ,
171174 ) ,
172175 ) ;
173- return { selfUpdate, order, urls, baseDir } ;
176+ return { selfUpdate, order, urls, baseDir, preflightProtocols } ;
174177} ) ;
175178
176179it . layer ( NodeServices . layer ) ( "server self update" , ( it ) => {
@@ -209,6 +212,15 @@ it.layer(NodeServices.layer)("server self update", (it) => {
209212 } ) ,
210213 ) ;
211214
215+ // regression: #34502 a remote update never replaces the launcher, so it can be older than the server
216+ it . effect ( "names its launcher's protocol to the staged preflight, not its own" , ( ) =>
217+ Effect . gen ( function * ( ) {
218+ const { selfUpdate, preflightProtocols } = yield * makeHarness ( { launcherProtocol : 3 } ) ;
219+ expect ( ( yield * selfUpdate . update ( { targetVersion : "1.1.0" } ) ) . updateId ) . toBe ( "launcher-id" ) ;
220+ expect ( preflightProtocols ) . toEqual ( [ "3" ] ) ;
221+ } ) ,
222+ ) ;
223+
212224 // regression: #5181 make remote updates rollback-safe
213225 it . effect ( "rejects invalid versions and desktop-managed servers before staging" , ( ) =>
214226 Effect . gen ( function * ( ) {
0 commit comments