Suppress console.log & others inside the TS Server runtime so that language service plugins don't accidentally use them and kill the server#32668
Conversation
…guage service plugins don't accidentally use them and kill the server - fixes microsoft#31209
|
@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 |
| // 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
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. |
Fixes #31209 (where most of the discussion is)
This should probably hold till 3.7