Repository navigation
Closed
Labels
Description
Description
Goal, that i'm trying to achieve is to parse npm audit output and do some stuff with it. Unfortunately Npm.exec "audit" just fails with exception without output, so i've switched to CreateProcess.fromRawCommand approach.
Repro steps
I have this code:
CreateProcess.fromRawCommand npmPath ["audit"; "--no-color"]
|> CreateProcess.withTimeout (TimeSpan.FromMinutes 1.0)
|> CreateProcess.withWorkingDirectory npmParams.WorkingDirectory
|> CreateProcess.redirectOutput
|> CreateProcess.map parseOutput
|> Proc.run
Expected behavior
On pc's of some of my colleagues it works fine and everything is finished without any problems.
Actual behavior
On my same windows pc it hangs because of redirectOutput (tried to remove it - after that code works fine.)
In case of redirectOutput presented, execution log looks like this:
C:\source\(Path to my project)> "C:\Program Files\nodejs\npm.CMD" audit --no-color (In: false, Out: true, Err: true)
At least one redirection task did not finish:
ReadErrorTask: RanToCompletion, ReadOutputTask: WaitingForActivation, RedirectStdInTask: RanToCompletion
At least one redirection task did not finish:
ReadErrorTask: RanToCompletion, ReadOutputTask: WaitingForActivation, RedirectStdInTask: RanToCompletion
At least one redirection task did not finish:
ReadErrorTask: RanToCompletion, ReadOutputTask: WaitingForActivation, RedirectStdInTask: RanToCompletion
At least one redirection task did not finish:
ReadErrorTask: RanToCompletion, ReadOutputTask: WaitingForActivation, RedirectStdInTask: RanToCompletion
At least one redirection task did not finish:
ReadErrorTask: RanToCompletion, ReadOutputTask: WaitingForActivation, RedirectStdInTask: RanToCompletion
At least one redirection task did not finish:
ReadErrorTask: RanToCompletion, ReadOutputTask: WaitingForActivation, RedirectStdInTask: RanToCompletion
Related information
- Operating system: Windows 10
- Npm --version - 6.11.3, (also tried on 6.10.3, same problem)
- Ran on .NET Core 2.2, .NET Core 3.0, doesn't change anything.
- Indications of severity
- Version of FAKE:
fake --version FAKE 5 - F# Make (5.16.1) (this line is written to standard error, see https://github.com/fsharp/FAKE/issues/2066) FakePath: C:\Users\someUser\.dotnet\tools\.store\fake-cli\5.16.1\fake-cli\5.16.1\tools\netcoreapp2.1\any\Fake.Runtime.dll Paket.Core: 5.216.0
Activity
matthid commentedon Oct 3, 2019
Apparently something doesn't work as it should. Best case would be to have a standalone way to reproduce in order to debug this. As you already noticed that it works on another machine I wouldn't be surprised if it works on my machine as well.
So we can either:
The relevant code path is this: https://github.com/fsharp/FAKE/blob/921f1973c9f1f1b3d7ce14ef4cc4282b4e0b83ef/src/app/Fake.Core.Process/RawProc.fs#L184
sergey-bulavskiy commentedon Oct 3, 2019
@matthid yeah, i'll return to this issue a little bit later, when i'll have time. Thanks for insights, i'll try to debug it.
add test method for #2401
matthid commentedon Oct 4, 2019
I tried to reproduce but was unable to do so. I added some environment variables so in the next release you can set the environment variable
FAKE_DEBUG_PROCESS_HANG(andFAKE_ATTACH_DEBUGGERif you want to debug it) to get a crash and a mini-dump. Maybe that helps further analyzing this problem.sergey-bulavskiy commentedon Oct 8, 2019
@matthid Thank you, will do it
matthid commentedon Oct 8, 2019
@serjebulavsky You can use 5.16.2-alpha.1304
Basically you only need to update Fake.Core.Process
matthid commentedon Oct 13, 2019
Any updates on this?
sergey-bulavskiy commentedon Oct 14, 2019
Tried with
Core.Process 5.16.2-alpha.1304andFAKE_DEBUG_PROCESS_HANG = trueDump:
sergey-bulavskiy commentedon Oct 14, 2019
Sorry, i didn't specified additional output in the first message in the issue, full output looks like this, if it can help somehow:
So basically kill on timeout doesn't work because it cannot find this process.
And i don't have a possibility to debug it currently, sorry.
matthid commentedon Oct 14, 2019
Thanks, is this the full output with latest including the environment variables I suggested above?
sergey-bulavskiy commentedon Oct 14, 2019
@matthid Yes, this is all
matthid commentedon Oct 14, 2019
Ok, as you have no more time to debug, can you at least attach the debugger and somehow send me a full dump of the process (as I might be able to debug with it (if you can send me along the lockfile for the exact nuget versions you used)?
Basically, attach Visual Studio -> Create full dump -> (Zip it as it probably is big) -> Send it to me somehow, feel free to send via mail if this is something company specific (matthi.d at gmail dot com or root at matthid dot de).
We can try a minidump as well first but it will be another potential back and forth ;)
sergey-bulavskiy commentedon Oct 14, 2019
okay thanks, i will do it a little bit later :)
sergey-bulavskiy commentedon Oct 16, 2019
@matthid Hello, i've tried to reproduce it today to create a dump for you, but for some reason it stopped hanging. I haven't updated anything from yesterday (yesterdays evening it was reproducable), altough i have a small minidump from yesterday, i will send it to you.
matthid commentedon Oct 16, 2019
@serjebulavsky Thanks for sending the dump, sadly I couldn't see any more information in the dump besides something obvious - that there is some other thread still hanging in "ReadFile" (to read the pipe of stdout of the process):
Not sure why it would hang there when the process is already closed. Not sure what to do when you yourself cannot even reproduce it anymore. Being able to reproduce it somehow is still preferred, it is not that unlikely that there is an edge case somewhere and I'm not seeing it. Starting processes in .net is surprisingly difficult to do correctly (which is the main reason for our own API).
sergey-bulavskiy commentedon Oct 17, 2019
@matthid Today it is reproducable again. I've tried to change number of vulnerable libraries in package.json (which leads to drastically decreased size of output), but no success, still hanging. Maybe you have other ideas or requests that i can try to do on my pc. Unfortunately right now (for a week at least) i just don't have enough time to deeply dive into it and debug it myself, sorry.
matthid commentedon Oct 17, 2019
So your current workaround is to just "try again" I assume?
I'd still try to collect a full dump instead of the minidump (let me know if you need info hon how to do it), I hope it shows the running tasks in the parallel stacks window. Additionally, I can send you custom builds but that process will be painfully slow and include several back and forth.
sergey-bulavskiy commentedon Oct 17, 2019
@matthid no, i decided to work with built-in Npm helper audit command, without reading output, just the error code. For some reason npm helper doesn't provide output. It would be great if you will provide info on how to do it, thanks :)
matthid commentedon Oct 20, 2019
I still have not been able to reproduce this in any scenario. To track this down further I need the following:
FAKE_ATTACH_DEBUGGERorFAKE_DEBUG_PROCESS_HANG)Let me know if you encounter difficulties.
Probably not useful and takes a long time
Additionally the following might help:
Attach visual Studio, either via the "Choose Just-In-Time Debugger" or for example via process explorer. Make sure to select "Manually choose the debugging engines.":


If not already hit "break all"
Open "Parallel Stacks" window, it probably looks like this:

Install, open and setup DotPeek as symbol server (it is free)
Go to Tools->Options->Debugging->Symbols Add the symbol server url (for example

http://localhost:33417and press "Load all symbols" (see warning below):Go to Debugging->General and disable "Enable Just My Code" and enable "Enable .NET Framework source stepping"
Go to "Parallel Stacks" window -> Threads and copy all stacks, Go to "Parallel Stacks" window -> Tasks and copy all stacks and paste them here.
Add more options to debug fsprojects#2401
github-actions commentedon Jan 19, 2020
There has not been any activity in this issue for the last 3 months so it will be closed in 14 days if there is no activity.