From 406bd84875c7828e67942a0330ff5ecd7383b42c Mon Sep 17 00:00:00 2001 From: lash Date: Mon, 2 Dec 2024 14:53:18 +0000 Subject: [PATCH] Always reset persister in handler --- internal/handlers/ussd/menuhandler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index 87760bd..a93d637 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -114,6 +114,9 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource logg.WarnCtxf(ctx, "handler init called before it is ready or more than once", "state", h.st, "cache", h.ca) return r, nil } + defer func() { + h.pe = nil + }() h.st = h.pe.GetState() h.ca = h.pe.GetMemory() @@ -133,7 +136,6 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource logg.ErrorCtxf(ctx, "perister fail in handler", "state", h.st, "cache", h.ca) return r, fmt.Errorf("cannot get state and memory for handler") } - h.pe = nil logg.DebugCtxf(ctx, "handler has been initialized", "state", h.st, "cache", h.ca) -- 2.45.2