Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions extensions/positron-supervisor/src/HandshakeSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,19 @@ export class HandshakeSocket implements vscode.Disposable {
public static connect(socketPath: string, timeoutMs: number): Promise<KallichoreServerState> {
const handles = new PromiseHandles<KallichoreServerState>();

console.log(
`[HandshakeSocket] connect: starting cached-handshake retrieval from ` +
`${socketPath} (timeout ${timeoutMs}ms)`);

const socket = net.connect(socketPath);
let text = '';
socket.setEncoding('utf8');
socket.on('data', (chunk: string) => { text += chunk; });
socket.on('end', () => {
try {
handles.resolve(JSON.parse(text) as KallichoreServerState);
console.log(
`[HandshakeSocket] connect: cached handshake received from ${socketPath}`);
} catch (err) {
handles.reject(new Error(`Failed to parse handshake payload: ${err}`));
}
Expand Down
10 changes: 9 additions & 1 deletion extensions/positron-supervisor/src/KallichoreAdapterApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,15 @@ export class KCApi implements PositronSupervisorApi {
// succeeds even if our saved bearer token is stale; that lets us detect
// a stale connection here, before we make any authenticated calls that
// would fail with a confusing 401.
const status = await this._api.api.serverStatus();
this.log(`Requesting server status from ${connectionInfo} to verify reconnect target`);
let status: Awaited<ReturnType<typeof this._api.api.serverStatus>>;
try {
status = await this._api.api.serverStatus();
this.log(`Received server status from ${connectionInfo}`);
} catch (err) {
this.log(`serverStatus() request to ${connectionInfo} failed: ${summarizeError(err)}`);
throw err;
}

// If the server reports a different identity than the one we saved, the
// original server has gone away and something else is now answering at
Expand Down
6 changes: 5 additions & 1 deletion src/server-supervisor-handshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ export class SupervisorHandshakeBroker {
socket.on('error', (err) => this._readyReject(err));
} else {
// A window reading the cached payload back out: replay and close.
socket.end(this._cached);
const cached = this._cached;
console.log('[SupervisorHandshakeBroker] cached-handshake replay requested');
socket.end(cached, () => {
console.log('[SupervisorHandshakeBroker] cached-handshake replay completed');
});
}
}

Expand Down
Loading