Repository navigation
Commit a7ca284
authored
Route jsonrpc connection logging to the output channel instead of console (#1853)
* Route jsonrpc connection logging to the output channel instead of console
Motivation:
BaseLanguageClient's internal jsonrpc Connection was created with a
ConsoleLogger, so protocol-level diagnostics such as "Received response
message without id" (jsonrpc/src/common/connection.ts) only showed up in
VS Code's Developer Tools console. Extensions typically point users at
their own Output channel for troubleshooting, so these messages were
effectively invisible to end users and to extension authors reproducing
bug reports.
Approach:
Add an OutputChannelLogger that implements the jsonrpc Logger interface
(error/warn/info/log) by forwarding to a LogOutputChannel, mapping the
generic log() to outputChannel.info() since LogOutputChannel has no
generic log method. The module-level createConnection() now accepts an
optional lazy accessor (() => LogOutputChannel) and uses
OutputChannelLogger when provided, falling back to the previous
ConsoleLogger otherwise. BaseLanguageClient.createConnection() passes
"() => this.outputChannel" rather than a resolved channel so the output
channel keeps its existing lazy-creation semantics: a channel is still
only created the first time something is actually logged, matching the
behavior of the pre-existing this.error/warn/info/debug client methods
and shouldLogToOutputChannel().
Validation:
- npm run compile:client (tsc -b ./client/tsconfig.json) passes with no
errors, type-checked against the real @types/vscode LogOutputChannel
shape.
- cd client && npm run lint (eslint) passes clean.
- Traced call sites in jsonrpc/src/common/connection.ts to confirm
logger.error/warn/log are only invoked from message-processing paths,
never from connection setup, so the lazy output-channel accessor is
never forced eagerly and a session that never logs still creates no
output channel, preserving prior behavior for that case.
- Could not run this repo's client-node-tests integration suite (real
VS Code Insiders launched via @vscode/test-electron, as used in
build/azure-pipelines/darwin/build.yml): the sandbox this change was
developed in has no free disk space to download the ~300MB VS Code
build (ENOSPC), an environment constraint unrelated to this change.
There is no lighter-weight unit-test harness for client.ts in this
repo since everything under client-node-tests only runs inside a real
VS Code Electron process.
Report: #1613
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5 (via Claude Code)
* Introduce ChannelProvider interface instead of passing a getOutputChannel closure
Per review feedback, createConnection/OutputChannelLogger now take a
ChannelProvider ({ outputChannel: LogOutputChannel }) and the client
itself is passed in, rather than a bound () => this.outputChannel
function. BaseLanguageClient's outputChannel getter already satisfies
the interface structurally, so lazy output-channel creation is
unchanged.
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
* Route OutputChannelLogger through the client's guarded logging methods
Per Copilot's review comment, OutputChannelLogger previously dereferenced
channelProvider.outputChannel directly, bypassing BaseLanguageClient's
shouldLogToOutputChannel() guard. An in-flight JSON-RPC handler rejection
after shutdown() could still reach the logger and recreate a disposed
output channel for a stopped client. ChannelProvider now exposes
error/warn/info (matching the client's existing public logging methods)
and OutputChannelLogger calls those with notifications disabled, so the
stopped-state guard applies to protocol-level logging too.
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
* Add regression test for JSON-RPC diagnostics routing to the output channel
Per Copilot's review comment, adds a test in the 'Server output' suite
that triggers a jsonrpc-level diagnostic (a throwing notification
handler) and asserts it reaches the client's guarded error() method
(showNotification=false) rather than bypassing it, covering the routing
fixed in f739ee8.
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
* Add a regression test for the post-stop() output-channel guard
Copilot's review flagged that the earlier regression test (1282da8)
never verified "no channel is created before the first diagnostic".
Investigating client.ts shows the output channel is already created
during start() as a side effect of wiring the trace log-level
listener, unrelated to diagnostics, so that literal assertion would
be false. Instead this adds a test for the actual regression
f739ee8 fixed: a diagnostic logged after stop() must not recreate
the disposed output channel.
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
---------
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Co-authored-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>1 parent 87f5872 commit a7ca284
2 files changed
Lines changed: 78 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
243 | 295 | | |
244 | 296 | | |
245 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1836 | 1836 | | |
1837 | 1837 | | |
1838 | 1838 | | |
1839 | | - | |
| 1839 | + | |
1840 | 1840 | | |
1841 | 1841 | | |
1842 | 1842 | | |
| |||
2480 | 2480 | | |
2481 | 2481 | | |
2482 | 2482 | | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
2483 | 2506 | | |
2484 | 2507 | | |
2485 | 2508 | | |
| |||
2488 | 2511 | | |
2489 | 2512 | | |
2490 | 2513 | | |
2491 | | - | |
2492 | | - | |
| 2514 | + | |
| 2515 | + | |
2493 | 2516 | | |
2494 | 2517 | | |
2495 | 2518 | | |
| |||
0 commit comments