@@ -27,6 +27,7 @@ import {
2727 PROTOCOL_VERSION ,
2828 resolveGatewayStartupRetryAfterMs ,
2929 resolveSafeTimeoutDelayMs ,
30+ shouldPauseGatewayReconnect ,
3031} from "@openclaw/gateway-client/browser" ;
3132export type { EventFrame as GatewayEventFrame } from "@openclaw/gateway-client/browser" ;
3233import type {
@@ -54,8 +55,6 @@ import { generateUUID } from "../lib/uuid.ts";
5455import { createBrowserGatewaySocket } from "./gateway-browser-socket.ts" ;
5556import {
5657 enrichProtocolMismatchDetails ,
57- isLegacyGatewayBuildIdSchemaError ,
58- isNonRecoverableConnectError ,
5958 resolveGatewayErrorDetailCode ,
6059} from "./gateway-connect-errors.ts" ;
6160
@@ -288,7 +287,6 @@ export class GatewayBrowserClient {
288287 // Older shipped Gateways used a closed client schema. Downgrade once per
289288 // browser client; a document reload creates a fresh exact-identity attempt.
290289 private clientBuildIdCompatibilityDisabled = false ;
291- private clientBuildIdRetryBudgetUsed = false ;
292290 // Close/stop advances this generation before another socket can make stale hello work look active.
293291 private recovery = { value : "" , resolved : false , generation : 0 } ;
294292 private scopeUpgradeBinding : ScopeUpgradeBinding | null = null ;
@@ -380,7 +378,6 @@ export class GatewayBrowserClient {
380378 this . pendingDeviceTokenRetry = false ;
381379 this . deviceTokenRetryBudgetUsed = false ;
382380 this . clientBuildIdCompatibilityDisabled = false ;
383- this . clientBuildIdRetryBudgetUsed = false ;
384381 }
385382
386383 get connected ( ) {
@@ -587,11 +584,11 @@ export class GatewayBrowserClient {
587584 const connectErrorCode =
588585 err instanceof GatewayRequestError ? resolveGatewayErrorDetailCode ( err ) : null ;
589586 if (
590- ! this . clientBuildIdRetryBudgetUsed &&
591- isLegacyGatewayBuildIdSchemaError ( err , plan . params . client . buildId )
587+ ! this . clientBuildIdCompatibilityDisabled &&
588+ plan . params . client . buildId &&
589+ / i n v a l i d c o n n e c t p a r a m s .* u n e x p e c t e d p r o p e r t y .* b u i l d i d / iu. test ( err . message )
592590 ) {
593591 this . clientBuildIdCompatibilityDisabled = true ;
594- this . clientBuildIdRetryBudgetUsed = true ;
595592 this . client . resetReconnectBackoff ( 250 ) ;
596593 return { closeCode : CONNECT_FAILED_CLOSE_CODE , closeReason : "connect retry" } ;
597594 }
@@ -725,7 +722,10 @@ export class GatewayBrowserClient {
725722 const retry =
726723 connectErrorCode === ConnectErrorDetailCodes . AUTH_TOKEN_MISMATCH
727724 ? this . pendingDeviceTokenRetry
728- : ! isNonRecoverableConnectError ( connectError ) ;
725+ : ! shouldPauseGatewayReconnect ( {
726+ details : connectError ?. details ,
727+ protocolMismatchIsTerminal : true ,
728+ } ) ;
729729 return { retry, notify : true , pendingError : error } ;
730730 }
731731
0 commit comments