Skip to content

fix(debrid): run torbox usenet availibility batch checks in sequence#730

Closed
webstreamr wants to merge 1 commit intoViren070:mainfrom
webstreamr:torbox-check-nzbs-sequence
Closed

fix(debrid): run torbox usenet availibility batch checks in sequence#730
webstreamr wants to merge 1 commit intoViren070:mainfrom
webstreamr:torbox-check-nzbs-sequence

Conversation

@webstreamr
Copy link
Contributor

@webstreamr webstreamr commented Feb 13, 2026

first step to avoid 5/s errors in this endpoint. if requests are done in batches because they are more than 100, then they will run in sequence instead of parallel per add-on

Summary by CodeRabbit

Release Notes

Bug Fixes

  • Improved error handling and validation for Torbox USENET cached availability checks. Error messages are now more descriptive and informative, including comprehensive details about failures. This enhancement increases visibility into issues when they occur, allowing for faster issue resolution and strengthening the overall reliability of USENET cache checking on Torbox.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Walkthrough

Refactored Torbox USENET cached availability checks to replace parallel batch processing with sequential execution, whilst introducing enhanced error propagation and API response validation to improve error diagnostics and control flow clarity.

Changes

Cohort / File(s) Summary
Torbox API Error Handling
packages/core/src/debrid/torbox.ts
Replaced parallel Promise.all batching with sequential for-of loop. Added enhanced error propagation with statusCode, statusText, headers, and body details. Introduced API response shape validation with explicit array type checking. Consolidated duplicate error construction into single error path.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨ A rabbit hops through sequential dreams,
Where batches flow like gentle streams,
With errors caught in crystal light,
And validation holding tight—
The code now bounces, clean and bright! 🎯

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: converting parallel batch processing to sequential execution for Torbox USENET availability checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/core/src/debrid/torbox.ts`:
- Around line 210-218: The thrown DebridError in the instant-availability check
loses its structured metadata when later passed into convertTorBoxError; update
the catch/rehydration logic (the handler that currently calls convertTorBoxError
around the catch at line ~259) to detect DebridError instances and re-throw them
directly (if (err instanceof DebridError) throw err;) instead of converting,
otherwise continue to call convertTorBoxError(err) for non-DebridError errors so
statusCode/statusText/headers remain intact.
🧹 Nitpick comments (1)
packages/core/src/debrid/torbox.ts (1)

220-231: Add type: 'api_error' for consistency.

Other DebridError constructions in this file include type: 'api_error' (e.g., lines 144, 287, 327). Consider adding it here for consistency and better error classification.

♻️ Proposed fix
           if (!Array.isArray(result.data.data)) {
             throw new DebridError(
-              'Invalid response from Torbox API. Expected array, got object',
+              'Invalid response from Torbox API. Expected array',
               {
                 statusCode: result.metadata.status,
                 statusText: result.metadata.statusText,
                 code: 'UNKNOWN',
                 headers: result.metadata.headers,
                 body: result.data,
+                type: 'api_error',
               }
             );
           }

@webstreamr
Copy link
Contributor Author

webstreamr commented Feb 14, 2026

TorBox increased limits to 300/m which should be enough. Aiostreams should still switch to POST using more hashes, maybe 500 per call in sequence as ST does for torrents.

For that TorBox-App/torbox-sdk-js#2 is needed

@webstreamr webstreamr closed this Feb 14, 2026
@webstreamr webstreamr deleted the torbox-check-nzbs-sequence branch February 14, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant