From 3604875b5510c918a5de4c056baf97e3ec6b0e42 Mon Sep 17 00:00:00 2001 From: rope Date: Sat, 15 Aug 2026 22:09:33 +0100 Subject: [PATCH] spotify-player: slow the startup retry loop instead of multiplying it Co-Authored-By: Claude Opus 5 --- home-manager/fred.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/home-manager/fred.nix b/home-manager/fred.nix index fa385d2..66f3de5 100644 --- a/home-manager/fred.nix +++ b/home-manager/fred.nix @@ -84,10 +84,20 @@ in # The loop breaks on the first success, so a bigger bound costs nothing. # The CLI is no help here: `connect --name` resolves names against the Web # API device list, which doesn't contain the integrated device at all. + # + # Widen it by slowing the delay rather than by adding rounds: each round + # costs up to three Web API calls, and we now share the bundled client ID + # with every other spotify-player/ncspot user, so 60 one-second rounds was + # ~180 requests per launch into a shared rate-limit bucket (429s). 12 + # rounds five seconds apart covers the same 60s for a fifth of the calls. + # Both loops in this file are `for _ in 0..5` / `from_secs(1)`; the leading + # indentation is what pins each replacement to initialize_playback. postPatch = (old.postPatch or "") + '' substituteInPlace spotify_player/src/client/mod.rs \ --replace-fail " for _ in 0..5 {" \ - " for _ in 0..60 {" + " for _ in 0..12 {" \ + --replace-fail " let delay = std::time::Duration::from_secs(1);" \ + " let delay = std::time::Duration::from_secs(5);" ''; }); settings = {