revert(startup): keep open-scrobble sweep deferred for fast startup
Reverts7161c86f. Running the sweep synchronously before the listener could add up to 30s to restart-before-playback when a watch provider is unreachable, which regresses the deliberate startup-deferral fromdfa0f686. Prefer the fast-startup behavior and accept the small window where a resume immediately after restart may create a duplicate scrobble; the sweep returns to the deferred background-init list. (Panic-safety for that list is added in a follow-up commit.) Per PR #21 review decision. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-13
@@ -1023,6 +1023,11 @@ func main() {
|
||||
WithMatcher(historyimport.NewMatcher(historyRepo)).
|
||||
WithWatchState(watchstate.NewService(userStoreProvider).WithStableIdentityResolver(historyIdentity)).
|
||||
WithUserStoreProvider(userStoreProvider)
|
||||
backgroundInit = append(backgroundInit, func(ctx context.Context) {
|
||||
if err := watchProviderService.SweepOpenScrobbles(ctx); err != nil {
|
||||
slog.Warn("failed to sweep open watch provider scrobbles", "error", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
deps.SessionMgr = sessionMgr
|
||||
deps.PlaybackRealtimeHub = playback.NewRealtimeHub()
|
||||
@@ -1678,19 +1683,6 @@ func main() {
|
||||
}()
|
||||
}
|
||||
|
||||
// Stop scrobble sessions left open by the previous process BEFORE the
|
||||
// listener accepts playback requests, so a resume immediately after a
|
||||
// restart doesn't create overlapping/stale scrobbles on remote providers.
|
||||
// Bounded by a timeout so an unreachable provider can't hang startup (which
|
||||
// is why the rest of non-critical init stays deferred below).
|
||||
if watchProviderService != nil {
|
||||
sweepCtx, cancelSweep := context.WithTimeout(appCtx, 30*time.Second)
|
||||
if err := watchProviderService.SweepOpenScrobbles(sweepCtx); err != nil {
|
||||
slog.Warn("failed to sweep open watch provider scrobbles", "error", err)
|
||||
}
|
||||
cancelSweep()
|
||||
}
|
||||
|
||||
errCh := make(chan error, 2)
|
||||
go func() {
|
||||
slog.Info("HTTP server listening", "addr", cfg.Server.Listen)
|
||||
|
||||
Reference in New Issue
Block a user