diff --git a/channels/channels_fsm.go b/channels/channels_fsm.go index 02768eee..6b7ad6f4 100644 --- a/channels/channels_fsm.go +++ b/channels/channels_fsm.go @@ -222,9 +222,16 @@ func cleanupConnection(ctx fsm.Context, env ChannelEnvironment, channel internal if otherParty == env.ID() { otherParty = channel.Responder } - env.CleanupChannel(datatransfer.ChannelID{ID: channel.TransferID, Initiator: channel.Initiator, Responder: channel.Responder}) - env.Unprotect(otherParty, datatransfer.ChannelID{ID: channel.TransferID, Initiator: channel.Initiator, Responder: channel.Responder}.String()) - return ctx.Trigger(datatransfer.CleanupComplete) + + + // the state machine event loop will block on these calls if we don't spin up a go-routine here. + go func() { + env.CleanupChannel(datatransfer.ChannelID{ID: channel.TransferID, Initiator: channel.Initiator, Responder: channel.Responder}) + env.Unprotect(otherParty, datatransfer.ChannelID{ID: channel.TransferID, Initiator: channel.Initiator, Responder: channel.Responder}.String()) + _ = ctx.Trigger(datatransfer.CleanupComplete) + }() + + return nil } // CleanupStates are the penultimate states for a channel