From db18e6e1d2cf763ee1b12ad755502c09a0dcbb64 Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Wed, 20 May 2026 21:48:44 +0200 Subject: [PATCH] instantout: use fresh contexts for cleanup Cleanup contexts were derived from caller contexts that may be canceled. Use independent timeout contexts for reservation unlocks and server cancel. --- instantout/actions.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/instantout/actions.go b/instantout/actions.go index 18c31d28..bc297f84 100644 --- a/instantout/actions.go +++ b/instantout/actions.go @@ -632,13 +632,15 @@ func (f *FSM) handleErrorAndUnlockReservations(ctx context.Context, err error) fsm.EventType { // We might get here from a canceled context, we create a new context // with a timeout to unlock the reservations. - ctx, cancel := context.WithTimeout(ctx, time.Second*30) + unlockCtx, cancel := context.WithTimeout( + context.Background(), time.Second*30, + ) defer cancel() // Unlock the reservations. for _, reservation := range f.InstantOut.Reservations { err := f.cfg.ReservationManager.UnlockReservation( - ctx, reservation.ID, + unlockCtx, reservation.ID, ) if err != nil { f.Errorf("error unlocking reservation: %v", err) @@ -650,7 +652,9 @@ func (f *FSM) handleErrorAndUnlockReservations(ctx context.Context, // release the reservations. This can be done in a goroutine as we // wan't to fail the fsm early. go func() { - ctx, cancel := context.WithTimeout(ctx, time.Second*30) + ctx, cancel := context.WithTimeout( + context.Background(), time.Second*30, + ) defer cancel() _, cancelErr := f.cfg.InstantOutClient.CancelInstantSwap( ctx, &swapserverrpc.CancelInstantSwapRequest{