A download client that times out leaves no record of the grab, because the timeout is read as a shutdown
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 25/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C#
- スター
- 901
- フォーク
- 70
- 平均マージ
- 16時間 27分
- マージ済み PR(30日)
- 60
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Listenarrs/Listenarr のほかの issue
-
Search button on a book does not retry without the author when the full query finds nothing対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Listenarrs/Listenarr#1173 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Listenarrs/Listenarr#1133 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Listenarrs/Listenarr#1128 ·
メンテナーはふだん 1 日以内に返信
-
Add New's search splits a title that contains "Series:", "Author:"… as if they were search keywordsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Listenarrs/Listenarr#1127 ·
メンテナーはふだん 1 日以内に返信
-
p3
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
Listenarrs/Listenarr#971 ·
メンテナーはふだん 1 日以内に返信
Listenarrs/Listenarr の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
conductor-oss/csharp-sdk#183 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
CreateNewLangProj throws when the default analysis writing system's ICU locale differs from its tagオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
unoplatform/uno#26555 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
CactuseSecurity/firewall-orchestrator#5739 ·
メンテナーはふだん 1 日以内に返信