madelson / MedallionShell

A .NET library simplifying the execution and chaining of processes
MIT License
415 stars 32 forks source link

The process hangs, console output is limited to 8 kb (MacOS, Windows) #79

Closed iamfreid closed 3 years ago

iamfreid commented 3 years ago

output.txt I run dotnet test process, in case the console gets a lot of output, the process hangs. I tried to do RedirectTo (new FileInfo ("output.txt")) and saw that the file only weighs 8 kb, and the console output was cut by half

                    var command = Command.Run("dotnet",
                        "test",
                        $"\"{Path.Combine(executeTask.PathToTests, executeTask.Project)}\"",
                        $"-c",
                        $"{executeTask.TargetConfiguration}",
                        $"-f",
                        $"{executeTask.TargetFramework}",
                        $"--filter",
                        $"TestCategory={guid}");
                    var result = command.Result;
                    if (!result.Success)
                    {
                        return $"error \n{result.StandardError}";
                    }
                    else
                    {
                        return result.StandardOutput;
                    }

If I run any process where there is little output, everything works correctly

The hang may be due to a long process execution, about 10 seconds. It is assumed that processes up to one hour will be launched

madelson commented 3 years ago

@iamfreid thanks for reporting!

Is it possible that there is a sub-process being spawned that is not exiting? The most common cause of hangs I see when consuming process output is because a subprocess inherits the standard output pipe. This keeps the pipe open which means that our call to Read() never returns.

If it is possible to upload a small solution .zip file that replicates this using the latest dotnet test, that would help in investigating!

madelson commented 3 years ago

Closing due to inactivity; feel free to reopen if you are able to provide more info.