From 10e3afc39fcb05ff05c43c3b7cbcce9c9f90f383 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Wed, 7 Aug 2024 13:46:49 +1000 Subject: [PATCH] fix: close stream for lease when lease expires (#2265) fixes #2215 When a module lease has an error (example ctx canceled due to the verb call ending), it used to leave the stream with the controller open forever. This change closes that stream. --- go-runtime/ftl/leases.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go-runtime/ftl/leases.go b/go-runtime/ftl/leases.go index 17e5d35d1..c4ea39568 100644 --- a/go-runtime/ftl/leases.go +++ b/go-runtime/ftl/leases.go @@ -129,6 +129,9 @@ func Lease(ctx context.Context, ttl time.Duration, key ...string) (LeaseHandle, } // Notify the handle. logger.Warnf("Lease heartbeat terminated for %s: %s", leaseKeyForLogs(module, key), err) + if err := lease.client.Release(ctx, key); err != nil { + logger.Warnf("Could not close lease %s: %s", leaseKeyForLogs(module, key), err) + } lease.state.open = false lease.state.err = optional.Some(err) return