Skip to content

Suppress console.log & others inside the TS Server runtime so that language service plugins don't accidentally use them and kill the server#32668

Merged
orta merged 2 commits intomicrosoft:masterfrom
orta:fix_31209
Aug 8, 2019
Merged

Suppress console.log & others inside the TS Server runtime so that language service plugins don't accidentally use them and kill the server#32668
orta merged 2 commits intomicrosoft:masterfrom
orta:fix_31209

Conversation

@orta
Copy link
Copy Markdown
Contributor

@orta orta commented Aug 1, 2019

Fixes #31209 (where most of the discussion is)

This should probably hold till 3.7

…guage service plugins don't accidentally use them and kill the server - fixes microsoft#31209
@weswigham
Copy link
Copy Markdown
Member

@RyanCavanaugh would it be possible to just use a private fd (spawning a process with extra pipes established is pretty easy in node) rather than stdout in most tsserver environments? We already use a socket for events... it should be a change to server.ts to not always make the readline instance from process.stdin and process.stdout.

Comment thread src/tsserver/server.ts Outdated
// the log. This is so that language service plugins which use
// console.log don't break the message passing between tsserver
// and the client
console.log = (msg) => logger.msg(msg, Msg.Info);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log/warn/error are normally variadic in node, so would it make sense to do something with all ...args in this replacement function? We'd be less likely to lose important information if a plugin passed multiple things to one log call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the logger accepts variadic args - we can pass the array joined as a string if args.length is greater than 1 though.

@orta
Copy link
Copy Markdown
Contributor Author

orta commented Aug 6, 2019

We chatted about this and the idea of using a private file descriptor for tsserver comms would be a good move, but that requires all tsserver editors making changes to handle that instead of stdin/stdout - so this should be a good enough for now.

@orta orta merged commit b70f894 into microsoft:master Aug 8, 2019
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TSServer: RangeError: Index out of range, exits with code: 134

3 participants