Powershell Windows Output stops after ~100 lines

Hi Folks,
I’m trying a cross-platform build with Maven and it works great on linux, but on Windows it stops outputting anything to stdout or stderr after about 100 lines; right when the JUnit tests begin.

Any thoughts or similar experiences?

Hi @mikedombo,

Thank you for being here!
Is there any error reported? Did you try to pipe the test result and then for check? Could you please share your repo/sample repo for further investigation?


This is the end of the output that we get. Just before this output is the beginning of our test run output, we’d expect many many more lines, so powershell is definitely hiding some output. Our tests fail, which is fine, so that’s why powershell shows the exit code of 1.

mvn : Threads are still running: [surefire-forkedjvm-command-thread, junit-jupiter-timeout-watcher]
At C:\actions-runner\_work\_temp\906e8779-c2d0-4cad-98f4-c18f1230df36.ps1:2 char:1
+ mvn -ntp -U clean verify 2>&1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Threads are sti...imeout-watcher]:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
##[error]Process completed with exit code 1.

Sorry, but I cannot share the repository with you. I’ll see if I can get an example that has the same issue.

I tried to just redirect the output to a file, but even the file was missing most of the output. This is very strange indeed because when we run the same maven command interactively, we do see all of the output. So it seems like there’s somethin different either in powershell or maven when not running interactively.

Hi @mikedombo,

Thanks for your reply!
This error could be caused by that command doesn’t exit properly. Please add & exit 0 with your script or command. Please refer to the similar ticket for your reference.
Besides, if the workflow logs do not provide enough detail to diagnose why a workflow, job, or step is not working as expected, you can enable additional debug logging. Please check doc here for more details.


Sorry, but that’s not correct. Exiting with a failure is correct because the build failed.

The timeline is
Start maven
Get 100 lines of output
Junit surefire tests start
Get a couple more lines of output
10 minutes later, when the tests have been outputting thousands of lines which don’t appear, then maven exits 1 because the build failed.

We should have tons of logs, the same that we get on Linux, during the 10 minutes of testing. However, nothing shows up until the error message that it exited non-zero, which again is expected.

Running the same command in powershell on the same host works as expected and we get all the standard output

Hi @mikedombo,

The runner prepends $erroractionpreference='stop' which may halt execution. Could you please add $erroractionpreference = 'continue' to your script for a try?
Add & exit 0 to the command will not affact the test result, but help to return an exit code to runner.
Please also try to enable debug logging, and if possible provide more error details for further investigation.


Adding & exit 0 doesn’t work due to

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double 
quotation marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : AmpersandNotAllowed

The answer is related to $erroractionpreference. It would seem that Powershell is reading our stderr and, when it sees the first line from that it throws the NativeCommandError, then it stops outputting all of our stdout and stderr. The command continue to execute all the tests, but eventually fails.

There are some weird ways to disable this behavior on powershell, but I think the best solution for us is to just fallback to cmd instead of powershell.