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

Run Recovery middleware's error handler in a goroutine #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Run Recovery middleware's error handler in a goroutine #165

wants to merge 1 commit into from

Conversation

pjebs
Copy link
Contributor

@pjebs pjebs commented Jan 4, 2017

-Addresses:
#147 (comment)

@pjebs pjebs mentioned this pull request Jan 4, 2017
@jszwedko
Copy link
Contributor

jszwedko commented Jan 8, 2017

@pjebs looks like there are some race conditions introduced by this.

I'd still like to see some benchmarks motivating this change, but I can plan on running some after the race conditions are addressed.

@pjebs
Copy link
Contributor Author

pjebs commented Jan 9, 2017

Are you sure the race conditions were introduced by this change or were they already there?
I can't see how that one line of code introduced a race condition

@jszwedko
Copy link
Contributor

jszwedko commented Jan 9, 2017

@pjebs I'm unable to reproduce on master, but am able to consistently reproduce given your patch.

Given that you are adding an additional goroutine, I don't think it is too surprising that race conditions might be introduced.

@trevrosen
Copy link
Contributor

Any movement on this? A quick scan indicates that it would solve the issue I filed in
#244

@jszwedko
Copy link
Contributor

@trevrosen It looks like you opened #245 after this comment so I assume you realized this wouldn't help with #244, but let me know if you still think it would (I'm not seeing how).

I'm still not sure this PR is necessary, but I'm open to thoughts. It is possible to spin off a goroutine in the provided ErrorHandlerFunc if the user really wants to.

go test ./... -race is still showing race conditions as well, but looking more closely, they may be due to the way the logger is being mocked in the tests with a bytes.Buffer

@trevrosen
Copy link
Contributor

Yeah I rescind my earlier comment. I'm not sure what I must've been looking at before, lol...

IMHO the PR isn't strictly necessary. The user can choose to go in their function as you mention, and running recovery handlers in their own goroutine is an opinion that I'd expect a small lib like Negroni to not have.

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.

3 participants