-
Notifications
You must be signed in to change notification settings - Fork 72
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
soroban-rpc: add generic panic handing #856
Conversation
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.
nice integration!
I don't think it's kosher to use camelCase in filenames |
I'm ok changing that. would |
I don't think it's kosher to use underscores either, I think, but we are already going it at different places. See https://stackoverflow.com/a/39625565/1914440 |
The link you've provided suggeted that
are legitimate. I'm open to changing the file names, but please be more specific - how would you like to call the file ? |
Two questions:
Also, if we were to use logs for the panics, I am not a fan of reporting the panic across multiple log lines. Finally I am not a fan of the |
|
Lastly, have you seen https://github.com/gregwebs/go-recovery ? It may not be worth using such small library but it's ergonomics/API are a bit nicer. |
I think that this library would give us less than what this PR does. With this PR:
The technique used in that library is the same that is being used in this PR, so I really don't see much value in using it. |
The issue is that we're not the ones that run the process - and we can't "force" third parties to work in a specific way. This PR would ensure that we have the output on both the stderr as well as the log output. That way, the information is guaranteed to be "there". |
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.
Overall having a utility to standardize panic/recover workflows seems like a good idea. I think the thing holding this PR back is the API.
I see a few ideas to experiment with to get a nicer API here:
- we could try renaming the struct (
panicgroup
?) or even using the package name as part of the name:recovery.Go(cfg, func())
, orpanicgroup.Group
type thing - We could try breaking up the different handlers into different tools: one for logging, one for exiting, then offering a way to compose them.
- We could draw stricter boundaries around what this struct does, to trim down the options and make the interactions more clear. E.g. do we need both
Log
andLogPanicsToStdErr
? - We could have a valid zero-value for MonitoredRoutine, letting you do:
Routine{}.Go(func(){})
. Not sure if this would help? - something else entirely?
// instead of a thing you pass your func to, maybe
// a thing you use within your func:
func() {
defer recovery.Handler(
recovery.Log(logger),
recovery.ExitProcess(),
)
doRisky()
}()
looking onto the feedback here, I think that it's not 100% clear where we take this PR. It's also won't makes a ton of difference exactly how it's implemented. I'll try to adopt some of Paul's suggestions:
|
What
We've recently received a crash log from one of our partners ( see blow ).
The goal of this PR is to ensure that the next time we get a log, it would be actionable.
Why
The panic itself wasn't reported to the log. That would prevent us from handling these issues.
Known limitations
Adding the monitored to each of the go routines seems to be laborious. It does add some potential interesting features such as resiliency to panics.
Test output
Received Log