mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.19k stars 851 forks source link

Console should always flush after writing a newline #1726

Open andreabergia opened 4 days ago

andreabergia commented 4 days ago

Not really sure this deserves a big description. 🙂 We just want to ensure that any console.log actually ends up being printed immediately and not buffered.

gbrail commented 10 hours ago

Actually...

I'm not convinced that this is a good idea. "ShellConsole" is a thin abstraction that wraps various types of output streams (PrintWriters, which wrap PrintStreams, in this case), that already has the same abstraction for printing and flushing that Java streams have had forever.

Adding "flush" calls is something that seems trivial and will probably help in some cases, but in others it could have a huge performance impact, and I'd rather not break those folks.

Depending on the use case, MAYBE console.log itself (or perhaps the ShellConsolePrinter) class should flush, but I'm not even sure of that.

Can you talk about the use case that's driving this?