Skip to content

Commit f04c7ed

Browse files
committed
Supress console.log & others inside the TS Server runtime so that language service plugins don't accidentally use them and kill the server - fixes microsoft#31209
1 parent 33f362a commit f04c7ed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/tsserver/server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,4 +970,12 @@ namespace ts.server {
970970
if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
971971
ts.sys.tryEnableSourceMapsForHost();
972972
}
973+
974+
// Overwrites the current console messages to instead write to
975+
// the log. This is so that language service plugins which use
976+
// console.log don't break the message passing between tsserver
977+
// and the client
978+
console.log = (msg) => logger.msg(msg, Msg.Info);
979+
console.warn = (msg) => logger.msg(msg, Msg.Err);
980+
console.error = (msg) => logger.msg(msg, Msg.Err);
973981
}

0 commit comments

Comments
 (0)