From 5c637b72091d1ad611565dcba6a70e5b0c810764 Mon Sep 17 00:00:00 2001 From: "jinda.ljd" Date: Tue, 30 Dec 2025 20:04:25 +0800 Subject: [PATCH] fix: prevent potential panic in Shutdown when EventsService is nil Add nil check before calling EventsService.Close() to prevent panic when daemon.EventsService is not initialized during shutdown. Signed-off-by: jinda.ljd --- daemon/daemon.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index e809ba4c64..18b9cbbb0d 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1498,7 +1498,9 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error { // running anymore. If there are still some open connections to the // '/events' endpoint, closing the EventsService should tear them down // immediately. - daemon.EventsService.Close() + if daemon.EventsService != nil { + daemon.EventsService.Close() + } return daemon.cleanupMounts(cfg) }