fix(api): Remove throw when directOnly set to true#568
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughRemoved a conditional guard in Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant LosslessAPI
participant HiFiDirect
participant InstanceBackend
Client->>LosslessAPI: request (search / fetch)
LosslessAPI->>HiFiDirect: attempt direct fetch
HiFiDirect-->>LosslessAPI: error
Note right of LosslessAPI: log warning and continue
LosslessAPI->>InstanceBackend: instance-based fallback fetch/retry
InstanceBackend-->>LosslessAPI: response
LosslessAPI-->>Client: final response
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adjusts LosslessAPI.fetchWithRetry / search behavior so direct-query failures no longer immediately throw when directOnly is used, allowing fallback behavior to proceed.
Changes:
- Removed the
options.directOnlyearly rethrow infetchWithRetry’s direct-query path. - Stopped passing
directOnly: truefromsearch()when calling the combined/search/?q=endpoint.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| try { | ||
| // Keep direct TIDAL combined search behavior for normal mode. | ||
| // If direct query fails, fall back to hifi-api-compatible scoped searches (?s, ?a, ?al, ?v, ?p). |
There was a problem hiding this comment.
The comment says “If direct query fails, fall back to ... scoped searches”, but fetchWithRetry will now fall back to configured API instances first when the direct query fails, meaning scoped-search fallback won’t necessarily happen. Please update the comment to match the actual behavior (or adjust the logic if the intent is to always skip instance fallback here).
| // If direct query fails, fall back to hifi-api-compatible scoped searches (?s, ?a, ?al, ?v, ?p). | |
| // If the direct query fails, fetchWithRetry may first retry via configured API instances; | |
| // if no usable combined result is returned, fall back to hifi-api-compatible scoped searches (?s, ?a, ?al, ?v, ?p). |
| return await HiFiClient.instance.query(relativePath); | ||
| } catch (err) { |
There was a problem hiding this comment.
fetchWithRetry ignores options.signal for the direct-path request (HiFiClient.instance.query(...)), so callers providing an AbortSignal/timeout won't be able to cancel direct queries. Also, if the direct request is aborted (AbortError), the current catch will swallow it and proceed to fall back to instance fetches, defeating cancellation. Pass options.signal into query(...) and rethrow AbortError in the catch (similar to the later fetch loop).
| return await HiFiClient.instance.query(relativePath); | |
| } catch (err) { | |
| return await HiFiClient.instance.query(relativePath, { signal: options.signal }); | |
| } catch (err) { | |
| if (err?.name === 'AbortError') { | |
| throw err; | |
| } |
d570578 to
4777492
Compare
Description
Type of Change
Checklist
By submitting this PR, I agree to follow the guidelines. I understand that the final decision to merge rests with the maintainers and that not all contributions can be accepted.
Summary by CodeRabbit