protocolServerHandler.ts ×9

Frontier kind: Code frontier

unlabeled · c_992e4299a7a8

12 tests · 28526 LOC · 148 files · introduces 0 tests · 62 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges62 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2695 ranges28526 lines · 148 files · Browse complete extent
All tests (intent)
12 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 62 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/protocolServerHandler.ts 62 introduced LOC · 9 ranges

Open complete file

421 }
422 if (!client && msg.method === 'reconnect') {
423 > let responsePromise: Promise<unknown>; protocolServerHandler.ts
424 > try {
425 > const result = this._handleReconnect(msg.params, transport, disposables);
426 > client = result.client;
427 > responsePromise = result.responsePromise;
428 > } catch (err) {
429 transport.send(jsonRpcErrorFrom(msg.id, err));
430 return;
431 }
432 > responsePromise.then( protocolServerHandler.ts
433 > response => transport.send(jsonRpcSuccess(msg.id, response)),
434 > err => transport.send(jsonRpcErrorFrom(msg.id, err)),
435 > );
436 > return;
437 > }
438
439 // The VS Code upgrade request rides on the same transport but
661
662 private _handleReconnect(
663 > params: ReconnectParams, protocolServerHandler.ts
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 /**
724 */
725 private async _restoreReconnectSubscriptions(
726 > client: IConnectedClient, protocolServerHandler.ts
727 > params: ReconnectParams,
728 > canReplay: boolean,
729 > ): Promise<unknown> {
730 > const missing: string[] = [];
731 > const snapshots = await Promise.all(params.subscriptions.map(async sub => {
732 const key = sub.toString();
733 const classified = classifyChannel(key);
768 return undefined;
769 }
771 >
772 > this._reconcileActiveClientsAfterReconnect(client);
773 >
774 > if (canReplay) {
775 const actions: ActionEnvelope[] = [];
776 for (const envelope of this._replayBuffer) {
784 }
785 return { type: 'snapshot', snapshots: snapshots.filter((s): s is IStateSnapshot => s !== undefined) };
787
788 /**
794 */
795 private _reconcileActiveClientsAfterReconnect(client: IConnectedClient): void {
796 > const record = this._clients.get(client.clientId); protocolServerHandler.ts
797 > const resubscribed = new Set<string>();
798 > for (const connection of record?.state === 'active' ? record.connections : [client]) {
799 > for (const sub of connection.subscriptions.values()) {
800 if (sub.kind === ChannelKind.State) {
801 resubscribed.add(sub.uri);
802 }
803 }
805 > for (const session of this._stateManager.getSessionUris()) {
806 const state = this._stateManager.getSessionState(session);
807 if (state && this._isActiveClient(state, client.clientId)) {