Skip to content

Commit

Permalink
Revert "fix(typescript-plugin): disconnect socket on error"
Browse files Browse the repository at this point in the history
This reverts commit 7e49c8c.
  • Loading branch information
johnsoncodehk committed Sep 3, 2024
1 parent 7e49c8c commit a6eaf97
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/typescript-plugin/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const pipes = new Map<string, 'unknown' | 'ready'>();

export const onSomePipeReadyCallbacks: (() => void)[] = [];

function waitingForNamedPipeServerReady(namedPipePath: string) {
function watchNamedPipeReady(namedPipePath: string) {
const socket = net.connect(namedPipePath);
const start = Date.now();
socket.on('connect', () => {
Expand All @@ -49,10 +49,6 @@ function waitingForNamedPipeServerReady(namedPipePath: string) {
pipes.delete(namedPipePath);
socket.end();
});
socket.on('timeout', () => {
pipes.delete(namedPipePath);
socket.end();
});
}

export function getNamedPipePath(projectKind: ts.server.ProjectKind.Configured | ts.server.ProjectKind.Inferred, key: number) {
Expand All @@ -72,14 +68,14 @@ export function getReadyNamedPipePaths() {
}
else if (!pipes.has(configuredPipe)) {
pipes.set(configuredPipe, 'unknown');
waitingForNamedPipeServerReady(configuredPipe);
watchNamedPipeReady(configuredPipe);
}
if (pipes.get(inferredPipe) === 'ready') {
inferredPipes.push(inferredPipe);
}
else if (!pipes.has(inferredPipe)) {
pipes.set(inferredPipe, 'unknown');
waitingForNamedPipeServerReady(inferredPipe);
watchNamedPipeReady(inferredPipe);
}
}
return {
Expand Down Expand Up @@ -108,13 +104,11 @@ export function connect(namedPipePath: string, timeout?: number) {
pipes.delete(namedPipePath);
cleanup();
resolve('error');
socket.end();
};
const onTimeout = () => {
cleanup();
resolve('timeout');
socket.end();
};
}
const cleanup = () => {
socket.off('connect', onConnect);
socket.off('error', onError);
Expand Down

0 comments on commit a6eaf97

Please sign in to comment.