A download client that times out leaves no record of the grab, because the timeout is read as a shutdown
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start with listenarr.application/Downloads/Submission/DownloadService.cs, especially SendToDownloadClientAsync and the cancellation handling around AddAsync. The issue includes a ready branch and two tests in tests/Features/Application/Downloads/Submission/DownloadServiceTests.cs; inspect those tests and the branch’s changes rather than duplicating work. The linked discussion of #882 describes the intended composition, and done means distinguishing client timeouts from genuine shutdown cancellation while preserving the two test outcomes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
DownloadService.SendToDownloadClientAsync hands the prepared submission to the gateway
with no cancellation token:
listenarr.application/Downloads/Submission/DownloadService.cs:337
submissionResult = await clientGateway.AddAsync(downloadClient, prepared);
IDownloadClientGateway.AddAsyncdeclaresCancellationToken ct = default
(listenarr.application/Downloads/Contracts/IDownloadClientGateway.cs:29-32), so the token
in play isNoneand the method has no way to ask whether anyone actually requested a
cancellation.
The next two arms are:DownloadService.cs:343-347,catch (OperationCanceledException), which removes the
provisionalDownloadrow and rethrows.DownloadService.cs:348-358, the general arm, which removes the row and wraps the cause
inDownloadClientSubmissionException.
AnHttpClientrequest timeout throwsTaskCanceledException, and that derives from
OperationCanceledException, so it takes the first arm. History is only written after the
client has accepted (DownloadService.cs:368-374), and the provisional row is gone, so a
grab against a download client that is down, unreachable or wedged ends with nothing
written anywhere. The caller sees a rawTaskCanceledException; the UI shows the release
simply not appearing.
I think the cost is that the next automatic search picks the same release again, with the
same result, and the user has no history entry to look at to work out why.
Reproducing it
On a generated library, with one monitored book that a configured indexer can satisfy:
- Configure a download client pointing at a host and port that accept the TCP connection
and then never answer. A listener that accepts and sleeps is enough; blackholing the
port so the connect itself hangs works too. - Trigger a search and grab for the book, either from the UI or by letting the automatic
search cycle reach it. - Wait out the client's HTTP timeout.
- Check Activity and History. There is no entry for the attempt, and the queue has no row
either.
Contrast with a client that answers and refuses: that path takes the general arm and at
least surfacesDownloadClientSubmissionExceptionto the caller.
The branch
I have a branch ready: fix/submission-timeout-history, one commit
on top of a630572e.
- Threads a
CancellationTokenthroughStartDownloadAsyncand both
SendToDownloadClientAsyncoverloads intoAddAsync, defaulting todefaultso no
existing caller has to change. AutomaticSearchService.cs:308passesstoppingToken, which is the caller that actually
holds a shutdown token. The API controller
(listenarr.api/Features/Downloads/DownloadController.cs:90) keeps the default, since no
action in that controller binds a token today and making a browser disconnect cancel a
submission is a separate decision.- Narrows the cancel arm to
catch (OperationCanceledException) when (ct.IsCancellationRequested),
which is the same filterAutomaticSearchService.cs:114already uses around its own
cycle, and dropsOperationCanceledExceptionfrom the general arm's exclusion list so
everything else falls through to it. - No change to
IDownloadClientGateway; it already took an optional token on every method. DownloadService.csstays at 498 lines.
Two tests, both in
tests/Features/Application/Downloads/Submission/DownloadServiceTests.cs:- the gateway throws
TaskCanceledExceptionwhile nothing has requested cancellation, and
the call must surfaceDownloadClientSubmissionExceptionwrapping it; - the gateway throws a cancellation carrying a token that genuinely is cancelled, and the
call must still propagate it untouched, with no failure recorded.
Reverting the catch narrowing fails the first and leaves the second passing. Full backend
suite green on the branch.
How this composes with #882
On canary alone the observable change is narrow: a timeout takes the general arm instead of
the cancel arm, so the caller gets DownloadClientSubmissionException rather than a bare
TaskCanceledException, and the API returns 502 rather than an unhandled cancellation. No
history row is written either way, because canary writes nothing on the failure path at
all. That is why the test asserts on the exception type rather than on a history entry.
#882 is what makes the general arm write a DownloadFailed event. With both in, a timed
out grab reaches that arm and does get a history row, which is the outcome worth having.
Its commit message says cancellation is left alone because a shutdown is not a release
failure, and I agree with that as stated; the point here is only that today the code cannot
tell a shutdown from a timeout, because our own token never reaches the call.
The two branches touch the same two catch arms in the same method, so they will conflict
textually. #882 first is cleaner: it moves RemoveProvisionalDownloadAsync out into
DownloadSubmissionFailureHandler and changes both arms, and this branch is then a two
line edit to the filters on top of that shape. The reverse order makes #882 re-resolve the
same hunks. #918 and #943 also touch DownloadService.cs but in other methods.
Open question
Whether the API path should pass HttpContext.RequestAborted. It would make a browser that
navigates away mid-submission count as a real cancellation rather than a failure, which
seems right, but it is a behaviour change on an endpoint that binds no token today and it
is not needed for the defect above, so the branch leaves it out.
Disclosure: drafted with Claude Code at my direction; I read the cited code at the stated commit and reviewed this before posting.
- Lenguaje dominante
- C#
- Estrellas
- 901
- Forks
- 70
- Merge medio
- 16 h 27 min
- PR fusionados (30 d)
- 60
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Listenarrs/Listenarr
-
Search button on a book does not retry without the author when the full query finds nothingPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Listenarrs/Listenarr#1173 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Listenarrs/Listenarr#1133 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Listenarrs/Listenarr#1128 ·
Los mantenedores suelen responder en 1 día
-
Add New's search splits a title that contains "Series:", "Author:"… as if they were search keywordsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Listenarrs/Listenarr#1127 ·
Los mantenedores suelen responder en 1 día
-
p3
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Listenarrs/Listenarr#971 ·
Los mantenedores suelen responder en 1 día
Todos los issues de Listenarrs/Listenarr
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
conductor-oss/csharp-sdk#183 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
CreateNewLangProj throws when the default analysis writing system's ICU locale differs from its tagAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
unoplatform/uno#26555 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
CactuseSecurity/firewall-orchestrator#5739 ·
Los mantenedores suelen responder en 1 día