Skip to content

Pass on GH request id#4663

Open
chrmarti wants to merge 1 commit intomainfrom
chrmarti/revolutionary-yak
Open

Pass on GH request id#4663
chrmarti wants to merge 1 commit intomainfrom
chrmarti/revolutionary-yak

Conversation

@chrmarti
Copy link
Collaborator

@chrmarti chrmarti commented Mar 24, 2026

Copilot AI review requested due to automatic review settings March 24, 2026 20:26
@chrmarti chrmarti enabled auto-merge March 24, 2026 20:26
@chrmarti chrmarti self-assigned this Mar 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the WebSocket chat transport to expose handshake request IDs (including GitHub’s request id) to higher layers, so callers can attach that metadata to errors/telemetry.

Changes:

  • Make IChatWebSocketManager.getOrCreateConnection synchronous and require callers to explicitly connect() the returned connection.
  • Expose requestId and gitHubRequestId on IChatWebSocketConnection and use them in WebSocket telemetry.
  • Attach gitHubRequestId to thrown errors when ChatMLFetcher fails to establish a WebSocket connection.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/platform/networking/node/test/chatWebSocketManager.spec.ts Updates test helper to explicitly connect() before sending requests.
src/platform/networking/node/chatWebSocketManager.ts Refactors connection lifecycle (caller-managed connect), and surfaces request IDs for telemetry/consumers.
src/extension/prompt/node/chatMLFetcher.ts Connects explicitly and propagates GitHub request id on connect failure.
Comments suppressed due to low confidence (2)

src/platform/networking/node/chatWebSocketManager.ts:137

  • getOrCreateConnection only reuses an existing connection when isOpen is true. With the new API where callers initiate connect(), a second call for the same conversation/turn while the first connection is still connecting will dispose the in-flight connection and create a new one, which can lead to duplicate connection attempts and leaked sockets/promises. Consider reusing the existing connection while it is connecting (or tracking a per-connection connect() promise/state) instead of disposing it just because it isn't open yet.

This issue also appears on line 335 of the same file.

		// Reuse the connection if it's for the same turn and still open.
		if (existing?.turnId === turnId && existing.connection.isOpen) {
			this._logService.debug(`[ChatWebSocketManager] Reusing connection for conversation ${conversationId} turn ${turnId}`);
			return existing.connection;
		}

src/platform/networking/node/chatWebSocketManager.ts:340

  • With getOrCreateConnection now returning an unconnected object, it becomes more likely that connect() could be invoked multiple times (or getOrCreateConnection called again) while a connection attempt is still in progress. Currently connect() does not guard against the Connecting state (only Open), so concurrent calls can trigger multiple createResponsesWebSocket() attempts and multiple event listener sets. Consider making connect() idempotent by returning the same in-flight promise while connecting, and ensure disposal during setup prevents the underlying socket from being left open.
			const onClose = (event: CloseEvent) => {
				cleanup();
				this._state = ConnectionState.Closed;
				this._responseHeaders = connection.responseHeaders;
				this._responseStatusCode = connection.responseStatusCode;
				this._responseStatusText = connection.responseStatusText;

@chrmarti chrmarti added this pull request to the merge queue Mar 24, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants