Skip to content

Prevent console output interference with LSP communication#1446

Merged
TheAngryByrd merged 1 commit intoionide:mainfrom
TheAngryByrd:disable-console-out
Feb 4, 2026
Merged

Prevent console output interference with LSP communication#1446
TheAngryByrd merged 1 commit intoionide:mainfrom
TheAngryByrd:disable-console-out

Conversation

@TheAngryByrd
Copy link
Member

@TheAngryByrd TheAngryByrd commented Feb 4, 2026

Try to handle rogue Console.Writelines from libraries we don't control.

ionide/ionide-vscode-fsharp#2102

Example in a f# script of this behavior:

open System
open System.IO

Console.SetOut(TextWriter.Null)
let cout = Console.OpenStandardOutput()
let tcout = new StreamWriter(cout)

Console.WriteLine("This will not be seen in the console.")
printfn "Neither will this."
Console.Out.WriteLine("This will also not be seen in the console.")
Console.Out.Flush()

tcout.WriteLine("This will be seen in the output stream.")
tcout.Flush()

The only other solution is to explore other transport means like sockets/pipes.

@TheAngryByrd TheAngryByrd requested a review from baronfel February 4, 2026 16:40
// Attempt to prevent any console output from interfering with the LSP communication from libraries that may use Console.WriteLine
// https://github.com/ionide/ionide-vscode-fsharp/issues/2102
// This is a best-effort mitigation; libraries that write directly to the underlying stream like (Console.OpenStandardOutput) may still interfere.
Console.SetOut(TextWriter.Null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, I love it :D

@TheAngryByrd TheAngryByrd merged commit a5c4e8e into ionide:main Feb 4, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants