[client, proxy] cancel context before stopping engine on embedded client

This commit is contained in:
mlsmaycon
2026-06-10 20:07:22 +02:00
parent 7feda907ca
commit eee33ec75f
2 changed files with 172 additions and 0 deletions
+4
View File
@@ -279,6 +279,10 @@ func (c *Client) Start(startCtx context.Context) error {
select {
case <-startCtx.Done():
// Cancel the client context before stopping: Engine.Start blocks on the
// signal stream while holding the engine mutex and only unblocks on
// cancellation. Stopping first would deadlock on that mutex.
cancel()
if stopErr := client.Stop(); stopErr != nil {
return fmt.Errorf("stop error after context done. Stop error: %w. Context done: %w", stopErr, startCtx.Err())
}