-
Notifications
You must be signed in to change notification settings - Fork 298
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
ensure withTimeout deals nicely with runtime.Goexit() #890
Conversation
9d07f7f
to
dec0ea4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rubensayshi, thanks for submitting this! Left a suggestion for a fix here.
Re: the error message, I believe withTimeout exit without returning
is a little too implementation-detail level error message for most users to comprehend.
Can we instead say something like: OnStart callback __ exited without returning
? (and it'd be OnStop callback exited...
for onstop callbacks).
I can also make those changes to this PR on your behalf if you want. Let me know
14b0570
to
e164e5f
Compare
updated to include both your suggestions, I don't think its strictly necessary as there isn't a race in the normal scenario, but with the boolean it might prevent odd future issues and it's more clear what the intention of the code is as well. I was thinking ... I think the only scenario where this gets triggered is a |
d2f77ad
to
04f31d2
Compare
updated to make the error get the wrapping with the "... hook added by ...", so an error looks like;
|
04f31d2
to
a2d8623
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes. There are linter and test failures that I wanted to address, but because this is a fork that lives in an organization, I couldn't push these changes directly to this PR. If you merge prvbl#1 into this branch that should update this PR.
243c2ca
to
bce7371
Compare
hey @sywhang thanks for that, you could have also commented and I would have changed, but much appreciated that you submitted the suggested changes ;) PR updated to include you changes. |
Codecov Report
@@ Coverage Diff @@
## master #890 +/- ##
=======================================
Coverage 98.53% 98.53%
=======================================
Files 30 30
Lines 1157 1163 +6
=======================================
+ Hits 1140 1146 +6
Misses 11 11
Partials 6 6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This looks good to me now. Looks like we aren't able to merge yet because the branch is out of date with the base branch. If you can make the branch up to date with base branch, we'll go ahead and merge this.
…thin the callback.
bce7371
to
5a41d4c
Compare
rebased, and thanks for helping me polish this <3 |
Great! Merging now. Thanks again for your contribution. |
We've been running our tests from an OnStart hook, but when one of the tests calls
t.FailNow()
it will under-the-hood callruntime.Goexit()
and then the OnStart hook just sits there waiting for the timeout...With this change the
withTimeout
can never get stuck when for some reasonruntime.Goexit()
got called.I'm not 100% sure returning the
fmt.Errorf("withTimeout exit without returning")
is the best choice,c <- nil
could also work, that would make it look like the callback succeeded and continue calling the nextOnStart
orOnStop
hook.