tfausak / purple-yolk

:hatching_chick: A Haskell IDE for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=taylorfausak.purple-yolk
MIT License
26 stars 2 forks source link

Child process crashes if there's too much output #13

Closed tfausak closed 4 years ago

tfausak commented 4 years ago

This surprised me! The process has a maximum output size. It defaults to 1 MB. If that much output is generated, the process crashes. https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback

maxBuffer <number> Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at maxBuffer and Unicode. Default: 1024 * 1024.

You can reliably crash GHCi by putting something like this in your .ghci:

Control.Monad.replicateM_ 1025 (putStrLn (replicate 1025 'x'))

This problem is surprisingly easy to run into when you have lots of modules. The default GHCi prompt is huge, and I often get lots of warnings for missing import lists.

One way to lessen the impact here would be to increase the max buffer size. I'm not sure what I would increase it to, and that's really only passing the buck. (Note that outputting less probably wouldn't help. This is Node's buffer, not VSCode's.)

I only ever want to stream output, so I should figure out how to set up the process to do that.

tfausak commented 4 years ago

I think this happened because I switched from spawn to exec. The former doesn't buffer STDIO at all whereas the latter buffers STDOUT and STDERR.

I switched to exec for the shell argument parsing, but it turns out you can get that with spawn using { shell: true }.