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

tsserver-bridge does not support node IPC, which is used by VSCode #5

Open
MarcCelani-at opened this issue Jun 27, 2022 · 1 comment

Comments

@MarcCelani-at
Copy link

in Typescript 4.6, tsserver began communicating with its parent process using ipc (see microsoft/TypeScript#46417). tsserver-bridge does not proxy messages to and from the parent process to the underlying tsserver, meaning that tsserver-bridge does not work with typescript 4.6+

@albertogasparin
Copy link

albertogasparin commented Jul 20, 2022

We hit the same issue, with TSServer needing 8GB+, so we have added support to TS4.6+

// tsserver.js
const { spawn } = require("child_process");
const path = require("path");
const process = require("process");

const nextArgv = process.argv.slice(2);
nextArgv.unshift(path.resolve(__dirname, "../lib/tsserver.js"));
nextArgv.unshift("--max_old_space_size=12288");

const child = spawn("node", nextArgv, {
  cwd: process.cwd(),
  env: process.env,
  stdio: ["pipe", "pipe", "pipe", "ipc"]
});

// forward messages to child
process.on("message", (msg) => child.send(msg));
// forward messages to parent
child.on("message", (msg) => process.send(msg));

// forward other statuses
["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "SIGTERM"].forEach((ev) => {
    process.on(ev, () => child.kill());
    child.on(ev, (code) => process.exit(code));
});

Haven't raised a PR as we are using patch-package to put this under node_modules/typescript/override/tsserver.js and then setting that as path for VSCode typescript.tsdk:

 "typescript.tsdk":"node_modules/typescript/override"

It's not perfect but does the job

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

No branches or pull requests

2 participants