Skip to content

Task [Publish_GitHub_Wiki_Content] hangs when it creates a large commit #111

@ykuijs

Description

@ykuijs

Details of the scenario you tried and the problem that is occurring

When the task "Publish_GitHub_Wiki_Content" implements a lot of changes which results in a large commit, it is possible that the call to the "git commit" hangs, which is causing a time-out and an error message:

This call:

Invoke-Git -WorkingDirectory $tempPath `
-Arguments @( 'commit', '--message', "`"$($localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`"" )

Hangs here:

if ($process.WaitForExit($TimeOut) -eq $true)

Troubleshooting revealed that a call to $process.StandardOutput.ReadToEnd() immediately after the call to WaitForExit unfreezes the process and causes it to complete successfully.

Steps to reproduce the problem

Start with an empty wiki repo and generate a large number of markdown files. The code will run into the two minute timeout and then throw an error about not being able to remove the temp folder.

Expected behavior

Create a successful commit

Current behavior

Throw an error message:

ERROR: Cannot remove the item at 'C:\Users\USER\AppData\Local\Temp\o3k3fxk0.hkt' because it is in use.
At C:\src\MODULE\output\RequiredModules\DscResource.DocGenerator\0.10.2\DscResource.DocGenerator.psm1:3440 char:9
+         Remove-Item -Path $tempPath -Recurse -Force
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At C:\src\MODULE\output\RequiredModules\DscResource.DocGenerator\0.10.2\tasks\Publish_GitHub_Wiki_Content.build.ps1:102 char:1
+ task Publish_GitHub_Wiki_Content {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Suggested solution to the issue

This issue is most probably caused by the fact that the git commit command generates a lot of data to the output stream, which is causing the buffer to become full and the git process to hang.....waiting until the buffer is emptied, so it can continue. Solution is to read the output buffer during the process, clearing the buffer so new messages can be added to the buffer.

More information can be found here:

The operating system the target node is running

Windows 11

Version and build of PowerShell the target node is running

v5.1

Version of the module that was used

v0.10.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue is a bug.help wantedThe issue is up for grabs for anyone in the community.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions