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

Make sure we wait for stdout/stderr pipes to be closed before calling Wait() #299

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

gabivlj
Copy link
Contributor

@gabivlj gabivlj commented Feb 6, 2024

Fixes #298

@gabivlj
Copy link
Contributor Author

gabivlj commented Feb 7, 2024

Hi @tomhjp! Could you take a look at these changes whenever you have a chance? Thank you!!

@tomhjp
Copy link
Contributor

tomhjp commented Feb 12, 2024

Thanks for the PR and the ping! I'd like to get a test for this fix, please could you share details on a repro? I can reliably repro if similarly to the previous issue I add a time.Sleep(time.Second) inside the stdout scanner loop, but I want to be sure that that's a faithful representation of the real scenario, i.e. is this a race condition that only pops up once in a while, or does it happen every time for your plugin?

@tomhjp
Copy link
Contributor

tomhjp commented Feb 12, 2024

I pushed a test that fails before this fix and passes after in 36c021d. LMK if you think that looks like a good test case.

@gabivlj
Copy link
Contributor Author

gabivlj commented Feb 12, 2024

Thank you @tomhjp for the test! I appreciate it a lot.
I think it's a good test case, as it will practically trigger that stderr exits before stdout and call the 'Wait()' syscall before stdout goroutine finishes.

We were encountering these logs "sometimes" in our error reports so it was just noise.

Copy link
Contributor

@tomhjp tomhjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the confirmation! In that case I'm convinced we've understood the bug sufficiently well to merge. I'll add the test in a follow up PR. Thanks again for the fix!

@tomhjp tomhjp merged commit 90c365e into hashicorp:main Feb 12, 2024
1 check passed
@tomhjp tomhjp mentioned this pull request May 10, 2024
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

Successfully merging this pull request may close these issues.

error encountered while scanning stdout: file already closed
2 participants