Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 28e96f8

Browse files
committed
Log suspicious stdout
1 parent 6118f11 commit 28e96f8

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
rules: {
1212
semi: ["warn", "never"],
1313
"no-unused-vars": "warn",
14-
"no-console": ["warn", { allow: ["info", "warn", "error"] }],
14+
"no-console": ["warn", { allow: ["debug", "info", "warn", "error"] }],
1515
"valid-jsdoc": ["warn", {
1616
requireParamDescription: false,
1717
requireReturn: false,

lib/index.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@ async function installRlsComponents(toolchain) {
173173
}
174174
}
175175

176+
/**
177+
* Adds a listener on stdout to warn of non-LSP looking lines (potentially from wayward
178+
* server-side printing). Non-LSP stdout usage will break vscode-jsonrpc.
179+
* @param {ChildProcess} process Rls
180+
* @return {ChildProcess}
181+
*/
182+
function logSuspiciousStdout(process) {
183+
process.stdout.on('data', chunk => {
184+
chunk.toString('utf8')
185+
.split('\n')
186+
.filter(l => l.trim() && !l.startsWith("Content-Length:") && !l.includes('"jsonrpc":"2.0"'))
187+
.forEach(line => console.error("Rust (RLS) suspicious stdout:", line))
188+
})
189+
return process
190+
}
191+
176192
// ongoing promise
177193
let _checkingRls
178194

@@ -555,21 +571,21 @@ class RustLanguageClient extends AutoLanguageClient {
555571
atom.notifications.addInfo(`Using rls command \`${cmdOverride}\``)
556572
this._warnedAboutRlsCommandOverride = true
557573
}
558-
return cp.spawn(cmdOverride, {
574+
return logSuspiciousStdout(cp.spawn(cmdOverride, {
559575
env: await serverEnv(configToolchain()),
560576
shell: true,
561577
cwd: projectPath
562-
})
578+
}))
563579
}
564580

565581
try {
566582
await this._checkToolchain()
567583
await checkRls(this.busySignalService)
568584
let toolchain = configToolchain()
569-
return cp.spawn("rustup", ["run", toolchain, "rls"], {
585+
return logSuspiciousStdout(cp.spawn("rustup", ["run", toolchain, "rls"], {
570586
env: await serverEnv(toolchain),
571587
cwd: projectPath
572-
})
588+
}))
573589
}
574590
catch (e) {
575591
throw new Error("failed to start server: " + e)

0 commit comments

Comments
 (0)