Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: use explicit context for notifications
Kyle Mendell6987b5e046c3
diff --git a/backend/internal/services/image_update_service.go b/backend/internal/services/image_update_service.goindex 7b0e1a0cb..9753051fc 100644--- a/backend/internal/services/image_update_service.go+++ b/backend/internal/services/image_update_service.go@@ -1334,10 +1334,14 @@ func (s *ImageUpdateService) sendBatchImageUpdateNotificationsInternal(ctx contedefer s.notifyMu.Unlock()// completeImageUpdateActivityInternal cancels the activity-tracked ctx before- // we reach here, so detach from that cancellation (mirrors the helper it uses)- // — otherwise the unnotified-updates query dies with "context canceled" and no- // notification is ever dispatched.- ctx = utils.ActivityRuntimeContext(ctx, nil)+ // we reach here, so detach from that cancellation — otherwise the+ // unnotified-updates query dies with "context canceled" and no notification is+ // ever dispatched. Deliberately not utils.ActivityRuntimeContext: that helper+ // short-circuits (returns ctx unchanged) for app-lifecycle-marked contexts, and+ // every request/scheduler ctx carries that marker via the server BaseContext,+ // making the detach a no-op in production. WithoutCancel keeps all values and+ // the WithTimeout below keeps the flush bounded.+ ctx = context.WithoutCancel(ctx)notifCtx, cancel := context.WithTimeout(ctx, 30*time.Second)defer cancel()diff --git a/backend/internal/services/image_update_service_test.go b/backend/internal/services/image_update_service_test.goindex 3c15fb1cd..4e51794c1 100644--- a/backend/internal/services/image_update_service_test.go+++ b/backend/internal/services/image_update_service_test.go@@ -16,6 +16,7 @@ import (ref "github.com/distribution/reference""github.com/getarcaneapp/arcane/backend/v2/internal/database""github.com/getarcaneapp/arcane/backend/v2/internal/models"+ "github.com/getarcaneapp/arcane/backend/v2/pkg/utils""github.com/getarcaneapp/arcane/types/v2/imageupdate"glsqlite "github.com/glebarez/sqlite"dockertypescontainer "github.com/moby/moby/api/types/container"@@ -1336,8 +1337,11 @@ func TestImageUpdateService_SendBatchNotifications_DetachesCanceledContext(t *te}require.NoError(t, db.Create(&rec).Error)- // Simulate the post-activity-completion state: the tracked ctx is already canceled.- ctx, cancel := context.WithCancel(context.Background())+ // Simulate the post-activity-completion state: the tracked ctx is already+ // canceled. Derive it from a lifecycle-marked parent to mirror production,+ // where every request/scheduler ctx inherits the marker via the server+ // BaseContext — the detach must work even then.+ ctx, cancel := context.WithCancel(utils.WithAppLifecycleContext(context.Background()))cancel()svc.sendBatchImageUpdateNotificationsInternal(ctx)