Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitForProcess throws a NoSuchThing exception if the process completes too quickly. #215

Open
ProofOfKeags opened this issue Sep 29, 2021 · 4 comments

Comments

@ProofOfKeags
Copy link

I have observed that if you call waitForProcess and the process has already completed, an exception is raised. This can be rather surprising since if you launch a process and it doesn't take a lot of time you can be unable to check whether or not it completed successfully by looking at the exit code.

@snoyberg
Copy link
Collaborator

I've never seen this, despite having test cases that include very short lived processes like true. Can you provide a repo, including exact versions of libraries and GHC, as well as OS? Ideally a Stack script would lock everything down.

@ProofOfKeags
Copy link
Author

It's possible that it isn't related to it being short lived, that part is speculation. The observed behavior is that if I launch several (4) processes using typed-process with conduit output streams via async actions, every so often one of them will fail on withProcessTerm or the variant withProcessTerm_. When I switch to withProcessWait, it never causes this particular issue.

When I drilled down, the exception being raised was that it was blocked indefinitely on an STM transaction and I figured out that this was due to waitExitCodeSTM blocking on a TMVar that would never be filled. The root cause of this is because waitForProcess raises a NoSuchThing variant of IOError and this would cascade to the ExitCode not being retrieved and consequently not fed to the TMVar. I was able to confirm this when I used the non-exit code checking variant. In this case the exception changed from STM blocking to waitForProcess "No child processes", which is called from within the various withProcessTerm calls.

I filed this bug here because I think the underlying issue is that waitForProcess seems like it should always succeed in this context, but it is possible the bug is in typed-process instead.

I will put together a small repo that can still produce this error today.

@bgamari
Copy link
Contributor

bgamari commented Jan 11, 2022

Any further updates on this, @ProofOfKeags ?

@ProofOfKeags
Copy link
Author

I completely forgot about this. No updates as of right now. Not sure when I'll be able to get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants