diff --git a/pkg/networkservice/common/timeout/server.go b/pkg/networkservice/common/timeout/server.go index 277028fea..71440b4d7 100644 --- a/pkg/networkservice/common/timeout/server.go +++ b/pkg/networkservice/common/timeout/server.go @@ -77,10 +77,11 @@ func (s *timeoutServer) Request(ctx context.Context, request *networkservice.Net afterCh := timeClock.After(timeClock.Until(expirationTime) - requestTimeout) go func(cancelCtx context.Context, afterCh <-chan time.Time) { + defer cancel() select { case <-cancelCtx.Done(): case <-afterCh: - eventFactory.Close(begin.CancelContext(cancelCtx)) + <-eventFactory.Close(begin.CancelContext(cancelCtx)) } }(cancelCtx, afterCh)