Description
I just wanted to thank you for this project, it's been incredibly useful!
Describe the bug
I noticed some behavior recently and I am not sure if it's due to a misconfiguration on my part or a bug. I have multi-scrobbler set up to scrobble from last.fm -> Maloja. Recently, the multi-scrobbler queue will get stuck where Queued Scrobbles
continues to go up while Tracks Scrobbled
and Failed Scrobbles
never increase. The logs are full of Cannot read properties of undefined (reading 'reduce')
errors (see full stack trace below).
From the logs, it seems like backlogged or recently played tracks from the source (last.fm), which have already been scrobbled, are failing to scrobble to Maloja as they are duplicates. My understanding is that would be expected behavior (I wouldn't want it to actually scrobble the duplicate). However, they appear to be causing the queue to get stuck instead of being ignored or showing up as Failed Scrobbles
.
If I delete the recent tracks from Maloja and restart multi-scrobbler, it successfully scrobbles them again and the queue continues to be processed from that point. However, as soon as multi-scrobbler is restarted it grabs a few recent tracks from last.fm, which have obviously already been scrobbled, and immediately gets stuck again.

Expected behavior
I would expect the previously scrobbled tracks to either be ignored (not attempted to scrobble them at all), or the duplicate error from Maloja would be handled and the track ignored.
Logs
Below are the logs for one of these events at startup. I included the maloja error as well (I have them in same systemd service)
multi-scrobbler-1 | [2024-08-25 19:10:23.433 -0700] DEBUG : [App] [Scrobblers] [Maloja - Maloja] <artist> - <track> @ 2024-08-23T17:32:01-07:00 (S) => No Match because no recent scrobbles returned from API
maloja-1 | [database] Incoming scrobble [Client: multi-scrobbler | API: native/v1]: {'track_artists': ['<artist>'], 'track_title': '<track>', 'album_title': '<album>', 'scrobble_time': 1724459521}
maloja-1 | [sqldb] 1 Scrobbles have not been written to database (already exist)
maloja-1 | Traceback (most recent call last):
maloja-1 | File "/venv/lib/python3.11/site-packages/maloja/apis/native_v1.py", line 126, in protector
maloja-1 | return func(*args,**kwargs)
maloja-1 | ^^^^^^^^^^^^^^^^^^^^
maloja-1 | File "/venv/lib/python3.11/site-packages/maloja/apis/native_v1.py", line 631, in post_scrobble
maloja-1 | result = database.incoming_scrobble(
maloja-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
maloja-1 | File "/venv/lib/python3.11/site-packages/maloja/database/__init__.py", line 115, in incoming_scrobble
maloja-1 | sqldb.add_scrobble(scrobbledict,update_album=albumupdate,dbconn=dbconn)
maloja-1 | File "/venv/lib/python3.11/site-packages/maloja/database/sqldb.py", line 159, in wrapper
maloja-1 | return func(*args,**kwargs)
maloja-1 | ^^^^^^^^^^^^^^^^^^^^
maloja-1 | File "/venv/lib/python3.11/site-packages/maloja/database/sqldb.py", line 364, in add_scrobble
maloja-1 | raise exc.DuplicateScrobble(scrobble=scrobbledict)
maloja-1 | maloja.database.exceptions.DuplicateScrobble
maloja-1 |
multi-scrobbler-1 | [2024-08-25 19:10:23.594 -0700] WARN : [App] [Scrobblers] [Maloja - Maloja] Maloja Warning: This scrobble exists in the database (same timestamp and track). The submitted scrobble was not added. => null
multi-scrobbler-1 | [2024-08-25 19:10:23.596 -0700] ERROR : [App] [Scrobblers] [Maloja - Maloja] Scrobble Error (Backlog)
multi-scrobbler-1 | [2024-08-25 19:10:23.598 -0700] DEBUG : [App] [Scrobblers] [Maloja - Maloja] Raw Payload:
multi-scrobbler-1 | [2024-08-25 19:10:23.598 -0700] ERROR : [App] [Scrobblers] [Maloja - Maloja] Scrobble processing interrupted
multi-scrobbler-1 | [2024-08-25 19:10:23.599 -0700] ERROR : [App] [Scrobblers] [Maloja - Maloja] Error occurred while trying to scrobble
multi-scrobbler-1 | Error: Error occurred while trying to scrobble
multi-scrobbler-1 | at MalojaScrobbler.doProcessing (CWD/src/backend/scrobblers/AbstractScrobbleClient.ts:598:39)
multi-scrobbler-1 | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
multi-scrobbler-1 | at MalojaScrobbler.startScrobbling (CWD/src/backend/scrobblers/AbstractScrobbleClient.ts:515:27)
multi-scrobbler-1 | caused by: TypeError: Cannot read properties of undefined (reading 'reduce')
multi-scrobbler-1 | at Function.formatPlayObj (CWD/src/backend/scrobblers/MalojaScrobbler.ts:99:39)
multi-scrobbler-1 | at MalojaScrobbler.formatPlayObj (CWD/src/backend/scrobblers/MalojaScrobbler.ts:128:90)
multi-scrobbler-1 | at MalojaScrobbler.doScrobble (CWD/src/backend/scrobblers/MalojaScrobbler.ts:465:38)
multi-scrobbler-1 | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
multi-scrobbler-1 | at MalojaScrobbler.doProcessing (CWD/src/backend/scrobblers/AbstractScrobbleClient.ts:589:51)
multi-scrobbler-1 | at MalojaScrobbler.startScrobbling (CWD/src/backend/scrobblers/AbstractScrobbleClient.ts:515:27)
multi-scrobbler-1 | [2024-08-25 19:10:23.611 -0700] INFO : [App] [Scrobblers] [Maloja - Maloja] Scrobble processing retries (0) less than max processing retries (5), restarting processing after 3 second delay...
One other interesting part of the logs I noticed was this:
[Scrobblers] [Maloja - Maloja] <artist> - <track> @ 2024-08-25T11:51:08-07:00 (S) => No Match because no recent scrobbles returned from API
Is there a chance this is caused by failing to get the list of recently scrobbled tracks from the Maloja api? The API appears to be working when querying it manually, at least.
I can include more logs, if that would be helpful.
Versions (please complete the following information):
- multi-scrobbler:
foxxmd/multi-scrobbler:latest
docker image (master-4fdd346) - maloja: 3.2.2