From ea9f2a236bbe5aa804ef2ebd951b27ae0f863201 Mon Sep 17 00:00:00 2001 From: Gusted Date: Thu, 19 Mar 2026 02:18:52 +0100 Subject: [PATCH] fix: only destroy session if exists The virtual session doesn't unconditionally call `Read` of the provider, which means it's possible for a session to not exists (created by the call to `Read`). To avoid that the call to `Destroy` fails with that the session does not exists, do also the exists check for `Destroy`. --- modules/session/virtual.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/session/virtual.go b/modules/session/virtual.go index cde9e60c4d..fea7d11a44 100644 --- a/modules/session/virtual.go +++ b/modules/session/virtual.go @@ -76,7 +76,10 @@ func (o *VirtualSessionProvider) Exist(sid string) bool { func (o *VirtualSessionProvider) Destroy(sid string) error { o.lock.Lock() defer o.lock.Unlock() - return o.provider.Destroy(sid) + if o.provider.Exist(sid) { + return o.provider.Destroy(sid) + } + return nil } // Regenerate regenerates a session store from old session ID to new one.