-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Use node ipc for TS Server #46418
Use node ipc for TS Server #46418
Conversation
For microsoft#46417 This lets us use Node's built-in ipc for passing messages to/from the typescript server instead of using stdio
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
src/tsserver/nodeServer.ts
Outdated
// TODO: Do we need any perf stuff here? | ||
// const msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); | ||
// perfLogger.logEvent(`Response message size: ${msgText.length}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the answer here might be yes, or at least the portion that formatMessage
does in verboseLogging
mode as a side effect.
The PR looks good to me as it is now (I don't see any gotchas), though I don't know if it's ready or if the VS Code side is done to test. |
@jakebailey This new flow should only be enabled if the client passes in the |
src/tsserver/nodeServer.ts
Outdated
@@ -715,6 +715,42 @@ namespace ts.server { | |||
this.constructed = true; | |||
} | |||
|
|||
public send(msg: protocol.Message) { | |||
if (useNodeIpc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider refactoring. The repeated flag check is a good indicator that you actually want method overrides. Maybe we're looking at a third subclass of Session
(WorkerSession
, IOSession
and maybe NodeIpcSession
?)
parseMessage
and toStringMessage
are the same as in the WorkerSession
implementation.
send
seems to be different for all three implementations, but does it need to be? That msg.type === "event"
check and logging code applies to all implementations so it may as well live in the base class. Then you probably want to pull out the writeMessage
call into a protected
method to make it specific to the subclass, since that's the part that actually differs between the three.
(I don't know if we want to follow these OOP patterns all across the codebase, but since the session code is written that way, my advice is following that pattern.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Made the fix
You'll need to accept the baseline for the public API. It seems like I don't have rights to change this branch though. |
@DanielRosenwasser When I run |
Maybe you're only doing a partial test-run? I think CI is correctly pointing out a change in private projectsUpdatedInBackgroundEvent;
logError(err: Error, cmd: string): void;
private logErrorWorker;
send(msg: protocol.Message): void;
+ protected writeMessage(msg: protocol.Message): void;
event<T extends object>(body: T, eventName: string): void;
/** @deprecated */
output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void;
private doOutput; |
Thanks! After running full tests I as able to run |
Thanks Matt! |
For #46417
This lets us use Node's built-in ipc for passing messages to/from the typescript server instead of using stdio
Needs review from the TS team because there are still a few todo comments and I'm pretty sure I've overlooked some things