Fix a race condition of not getting all the output in .NET Image #229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #200
There is a race condition in the .NET SDK. As observed in a local test,
Exited
event may fire before the lastOutputDataReceived
call. If that happens, the last chunk of the output won't be appended tostdout
. Theinspect
command returns a single chunk of output. If it's missing, the output is empty, and the exception"No digest available for image"
is fired.One possible fix would be to wait for a call with
e.Data
equal tonull
which signals the completion of the output.A simpler solution is suggested here and implemented in this PR: make and extra
WaitForExit
call in theProcessExited
handler. This flushes the buffers and lets the output sync in. My local tests confirmed the improvement: I don't get the issue anymore.Repro program that I used: https://gist.github.com/mikhailshilkov/978ae50e26c6e712c56fbd4d73b48222
In addition, I moved
Exited
event handler registration to before theStart()
call to avoid a potential miss. (I believe this is not related to this issue, though.)cc @Aaronontheweb @dbeattie71