Skip to content

Commit

Permalink
Supress console.log & others inside the TS Server runtime so that lan…
Browse files Browse the repository at this point in the history
…guage service plugins don't accidentally use them and kill the server - fixes microsoft#31209
  • Loading branch information
orta authored and a-tarasyuk committed Aug 9, 2019
1 parent 9851f9c commit 59fa462
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tsserver/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,4 +980,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 = (msg) => logger.msg(msg, Msg.Info);
console.warn = (msg) => logger.msg(msg, Msg.Err);
console.error = (msg) => logger.msg(msg, Msg.Err);
}

0 comments on commit 59fa462

Please sign in to comment.