661
662
private _handleReconnect(
664
>
transport: IProtocolTransport,
665
>
disposables: DisposableStore,
666
>
): { client: IConnectedClient; responsePromise: Promise<unknown> } {
667
>
this._logService.info(`[ProtocolServer] Reconnect: clientId=${params.clientId}, lastSeenSeq=${params.lastSeenServerSeq}`);
668
>
669
>
// Synchronously install the client so messages arriving on this transport
670
>
// while we restore subscriptions can find a valid client object. The
671
>
// reconnect response is only sent once `responsePromise` resolves below.
672
>
const client: IConnectedClient = {
673
>
clientId: params.clientId,
674
>
protocolVersion: PROTOCOL_VERSION,
675
>
transport,
676
>
subscriptions: new Map(),
677
>
disposables,
678
>
};
679
>
this._attachConnection(params.clientId, client);
680
>
681
>
// Re-establish the reverse-RPC filesystem authority for this client.
682
>
// The prior transport's `onClose` disposed the previous registration,
683
>
// so without this step any subsequent `resourceRead` / `resourceWrite`
684
>
// / etc. from the agent host would fail with "no connection registered
685
>
// for authority" until the client disconnected and re-initialized.
686
>
this._registerClientFileSystemAuthority(params.clientId, disposables);
687
>
688
>
const oldestBuffered = this._replayBuffer.length > 0 ? this._replayBuffer[0].serverSeq : this._stateManager.serverSeq;
689
>
const canReplay = params.lastSeenServerSeq >= oldestBuffered;
690
>
691
>
const responsePromise = this._restoreReconnectSubscriptions(client, params, canReplay);
692
>
return { client, responsePromise };
693
>
}
694
695
/**