fix(rtorrent): make adding torrent work with upstream json rpc enabled without extra config#930
Merged
Merged
Conversation
…d without extra config
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a compatibility issue with rTorrent when upstream JSON-RPC is enabled. The changes update the method names used for adding torrents to use non-throwing variants (load.start and load.normal instead of load.start_throw and load.throw), and removes hash extraction logic that was processing responses from the multicall.
- Changed method names from throwing to non-throwing variants for better compatibility
- Removed response processing logic that extracted torrent hashes from multicall responses
jesec
pushed a commit
that referenced
this pull request
Oct 26, 2025
## Problem Following PR #930's fix for file-based torrents, URL-based torrent addition still relied on the deprecated load.start_throw and load.throw methods. These methods were removed in rTorrent >0.15.1 and only exist as user-defined redirects (via method.redirect). Users without these redirects experienced failures when adding torrents via URL from external applications like Sonarr. ## Solution Implemented intelligent runtime detection that: 1. **Detects .throw method availability** via system.listMethods during service initialization 2. **Caches the result** per service instance (checked only once) 3. **Prioritizes .throw methods** when available (superior error reporting) 4. **Falls back gracefully** to load.normal/load.start when unavailable 5. **Assumes symmetry**: if load.throw exists, load.start_throw also exists (they're typically defined together) ## Implementation Details ### Detection Strategy - Calls system.listMethods during testGateway() - Checks for load.throw presence in method list - Caches result in loadThrowSupported property - Defaults to false on detection errors (safer default) ### Method Selection - getLoadMethodName(start) helper chooses correct method: - With .throw support: load.start_throw / load.throw - Without .throw support: load.start / load.normal ### Consistency Applied to both: - addTorrentsByURL (fixes the reported bug) - addTorrentsByFile (consistency + better error reporting) ## Deep Dive Research ### rTorrent Command History - **Native commands**: load.normal, load.start (exist in all versions) - **.throw variants**: NOT native, user-defined via method.redirect - **Purpose of .throw**: Better error reporting (throw vs silent failure) - **Deprecation**: Removed in rTorrent >0.15.1 ### JSON-RPC Behavior - Error -32601: Standard "Method not found" error - isJSONCapable ≠ .throw methods available - system.listMethods provides authoritative method list ### References - rTorrent source: src/command_events.cc defines load commands - JSON-RPC spec: github.com/jesec/rtorrent/discussions/52 - Method redirects: README.md lines 28-29 ## Testing ✅ TypeScript type checking passed ✅ ESLint passed (0 warnings) ✅ Works with and without .throw method redirects ✅ Maintains backwards compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Related Issue
Screenshots
Types of changes