Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix read streams blocking node threads #24652

Merged
merged 1 commit into from
Dec 23, 2024
Merged
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
12 changes: 10 additions & 2 deletions src/client/common/pipes/namedPipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CancellationError, CancellationToken, Disposable } from 'vscode';
import { traceVerbose } from '../../logging';
import { isWindows } from '../utils/platform';
import { createDeferred } from '../utils/async';
import { noop } from '../utils/misc';

const { XDG_RUNTIME_DIR } = process.env;
export function generateRandomPipeName(prefix: string): string {
Expand Down Expand Up @@ -187,6 +188,13 @@ export async function createReaderPipe(pipeName: string, token?: CancellationTok
} catch {
// Intentionally ignored
}
const reader = fs.createReadStream(pipeName, { encoding: 'utf-8' });
return new rpc.StreamMessageReader(reader, 'utf-8');
const fd = await fs.open(pipeName, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK);
const socket = new net.Socket({ fd });
const reader = new rpc.SocketMessageReader(socket, 'utf-8');
socket.on('close', () => {
fs.close(fd).catch(noop);
reader.dispose();
});

return reader;
}
Loading