@@ -30,6 +30,12 @@ const writeGatewayRestartHandoffSync = vi.fn((_opts: unknown) => ({
3030 restartKind : "full-process" as const ,
3131 supervisorMode : "external" as const ,
3232} ) ) ;
33+ const withGatewayRestartSkipStartupIngressSweepEnv = vi . fn (
34+ ( env : NodeJS . ProcessEnv | undefined ) => ( {
35+ ...env ,
36+ OPENCLAW_GATEWAY_RESTART_SKIP_STARTUP_INGRESS_SWEEP : "1" ,
37+ } ) ,
38+ ) ;
3339const scheduleGatewaySigusr1Restart = vi . fn ( ( _opts ?: { delayMs ?: number ; reason ?: string } ) => ( {
3440 ok : true ,
3541 pid : process . pid ,
@@ -140,6 +146,8 @@ vi.mock("../../infra/restart-sentinel.js", () => ({
140146} ) ) ;
141147
142148vi . mock ( "../../infra/restart-handoff.js" , ( ) => ( {
149+ withGatewayRestartSkipStartupIngressSweepEnv : ( env : NodeJS . ProcessEnv | undefined ) =>
150+ withGatewayRestartSkipStartupIngressSweepEnv ( env ) ,
143151 writeGatewayRestartHandoffSync : ( opts : unknown ) => writeGatewayRestartHandoffSync ( opts ) ,
144152} ) ) ;
145153
@@ -757,7 +765,10 @@ describe("runGatewayLoop", () => {
757765 waitForActiveTasks . mockResolvedValueOnce ( { drained : false } ) ;
758766 waitForActiveEmbeddedRuns . mockResolvedValueOnce ( { drained : true } ) ;
759767
760- type StartServer = ( ) => Promise < {
768+ type StartServer = ( params ?: {
769+ startupStartedAt ?: number ;
770+ inProcessRestart ?: boolean ;
771+ } ) => Promise < {
761772 close : GatewayCloseFn ;
762773 } > ;
763774
@@ -1369,6 +1380,7 @@ describe("runGatewayLoop", () => {
13691380 const [ respawnOpts ] = restartGatewayProcessWithFreshPid . mock . calls [ 0 ] ?? [ ] ;
13701381 expect ( respawnOpts ?. env ?. OPENCLAW_GATEWAY_RESTART_TRACE_STARTED_AT_MS ) . toMatch ( / ^ \d / u) ;
13711382 expect ( respawnOpts ?. env ?. OPENCLAW_GATEWAY_RESTART_TRACE_LAST_AT_MS ) . toMatch ( / ^ \d / u) ;
1383+ expect ( respawnOpts ?. env ?. OPENCLAW_GATEWAY_RESTART_SKIP_STARTUP_INGRESS_SWEEP ) . toBe ( "1" ) ;
13721384 expect ( writeGatewayRestartHandoffSync ) . not . toHaveBeenCalled ( ) ;
13731385 } ) ;
13741386 } finally {
@@ -1548,6 +1560,8 @@ describe("runGatewayLoop", () => {
15481560 await expect ( exited ) . resolves . toBe ( 0 ) ;
15491561 expect ( waitForHealthyChild ) . toHaveBeenCalledWith ( 18789 , 7777 , "127.0.0.1" ) ;
15501562 expect ( respawnGatewayProcessForUpdate ) . toHaveBeenCalledTimes ( 1 ) ;
1563+ const [ respawnOpts ] = respawnGatewayProcessForUpdate . mock . calls [ 0 ] ?? [ ] ;
1564+ expect ( respawnOpts ?. env ?. OPENCLAW_GATEWAY_RESTART_SKIP_STARTUP_INGRESS_SWEEP ) . toBe ( "1" ) ;
15511565 expect ( start ) . toHaveBeenCalledTimes ( 1 ) ;
15521566 expect ( markUpdateRestartSentinelFailure ) . not . toHaveBeenCalled ( ) ;
15531567 expect ( writeGatewayRestartHandoffSync ) . not . toHaveBeenCalled ( ) ;
0 commit comments