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 #31209
  • Loading branch information
orta committed Aug 1, 2019
1 parent 33f362a commit f04c7ed
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 @@ -970,4 +970,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 f04c7ed

Please sign in to comment.