Skip to content

Conversation

@geoknee
Copy link
Contributor

@geoknee geoknee commented Oct 18, 2025

Confirmed manually that with these changes, the process is exited instead of just stopping the "work" of the batcher only.

@geoknee geoknee marked this pull request as ready for review October 18, 2025 21:57
@geoknee geoknee requested review from a team as code owners October 18, 2025 21:57
@geoknee geoknee requested a review from scharissis October 18, 2025 21:57
Comment on lines +673 to +677
func (l *BatchSubmitter) shutdownOnCriticalError(err error) {
l.Log.Error("Shutting down batcher on critical error", "err", err)
// Call closeApp to trigger process to exit (gracefully)
l.closeApp(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

High Severity severity

Unprotected nil closeApp invocation can cause panic

The new shutdownOnCriticalError method unconditionally calls l.closeApp(err), which is passed as nil in many test and example invocations. This will cause a runtime panic when a critical throttling RPC error occurs, leading to an unintended crash.

Add a nil check before calling l.closeApp(err), or default to a safe no-op function if closeApp is not provided.


Don't like this finding? Reply "dismiss" and it won't appear again in future scans.

Comment on lines +673 to +677
func (l *BatchSubmitter) shutdownOnCriticalError(err error) {
l.Log.Error("Shutting down batcher on critical error", "err", err)
// Call closeApp to trigger process to exit (gracefully)
l.closeApp(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests for this would be good; does it shut down? Is it graceful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested this manually so far, and yes it does shut down successfully. I'm not totally sure we want to write a full end to end test for this, because we would need to spawn the batcher in a subprocess, attach it to an rpc endpoint returning MethodNotFound, and check on that process terminating. We don't have tests like this for sending an interrupt to the process, which should have the same effect. I'll see if I can add a little bit more unit tests to shore this up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extended an existing test here a57e224. I'm pretty happy with this level of testing, it shows the "closeApp" is called under the right conditions. Having that closeApp actually cause the process to exit is arguably out of scope, since this is generic behavior from op-service that we rely on for multiple services.

}
}

func isCriticalThrottlingRPCError(err error) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests for this would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Short & Sweet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-op-batcher Area: op-batcher

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants