Merge pull request #32668 from orta/fix_31209

Suppress console.log & others inside the TS Server runtime so that language service plugins don't accidentally use them and kill the server
This commit is contained in:
Orta 2019-08-08 08:56:35 -07:00 committed by GitHub
commit b70f894881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -982,4 +982,12 @@ namespace ts.server {
if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
ts.sys.tryEnableSourceMapsForHost();
}
// Overwrites the current console messages to instead write 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 = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Info);
console.warn = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err);
console.error = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err);
}