From d516584d905292df237a153d41de8182c6c599ce Mon Sep 17 00:00:00 2001 From: lash Date: Tue, 3 Dec 2024 16:16:46 +0000 Subject: [PATCH] Clear persister from handler in outer code aswell --- internal/handlers/base.go | 3 +++ internal/handlers/ussd/menuhandler.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/handlers/base.go b/internal/handlers/base.go index 4d2aa4c..755cca4 100644 --- a/internal/handlers/base.go +++ b/internal/handlers/base.go @@ -55,6 +55,9 @@ func(f *BaseSessionHandler) Process(rqs RequestSession) (RequestSession, error) } f.hn = f.hn.WithPersister(rqs.Storage.Persister) + defer func() { + f.hn.Exit() + }() eni := f.GetEngine(rqs.Config, f.rs, rqs.Storage.Persister) en, ok := eni.(*engine.DefaultEngine) if !ok { diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index a79d054..5c1caff 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -113,7 +113,7 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource return r, nil } defer func() { - h.pe = nil + h.Exit() }() h.st = h.pe.GetState() @@ -140,6 +140,10 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource return r, nil } +func (h *Handlers) Exit() { + h.pe = nil +} + // SetLanguage sets the language across the menu func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) { var res resource.Result -- 2.45.2