Skip to content

Fix: Disable OkHttp read timeout to prevent premature timeouts#43

Open
jacek-kupczyk-wenovate wants to merge 1 commit into
scanoss:mainfrom
cariad-optima:feat/add_configurable_read_timeout
Open

Fix: Disable OkHttp read timeout to prevent premature timeouts#43
jacek-kupczyk-wenovate wants to merge 1 commit into
scanoss:mainfrom
cariad-optima:feat/add_configurable_read_timeout

Conversation

@jacek-kupczyk-wenovate

@jacek-kupczyk-wenovate jacek-kupczyk-wenovate commented Jun 19, 2026

Copy link
Copy Markdown

This change disables OkHttp's default read timeout.

Previously, OkHttp applied a default 10 second read timeout, which caused requests to fail when processing larger payloads that the SCANOSS server could not complete within that time. By disabling the read timeout, the client no longer aborts these requests prematurely, allowing long-running responses to complete successfully.

Summary by CodeRabbit

  • Improvements
    • Updated HTTP client configuration to remove read timeout restrictions, improving reliability for extended API operations.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b50e36be-7d24-4851-b302-47666e31edf8

📥 Commits

Reviewing files that changed from the base of the PR and between 13a33cb and 2ffba3f.

📒 Files selected for processing (1)
  • src/main/java/com/scanoss/rest/ScanApi.java

📝 Walkthrough

Walkthrough

In ScanApi's constructor, when an OkHttpClient is built internally (i.e., no external client is supplied), the builder now also calls readTimeout(Duration.ZERO), disabling the read timeout so that only the configured callTimeout bounds HTTP requests.

Changes

Disable read timeout on internal OkHttpClient

Layer / File(s) Summary
Disable read timeout on internal HTTP client
src/main/java/com/scanoss/rest/ScanApi.java
Adds .readTimeout(Duration.ZERO) to the OkHttpClient.Builder used when no external client is provided, removing the read timeout and relying solely on callTimeout.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A rabbit hops past the timeout gate,
No read limit now, no need to wait!
The call timeout guards, steady and true,
While reads flow freely the whole session through.
🐇 Zero means endless — hop along, do! 🕐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 directly and accurately reflects the main change: disabling OkHttp's read timeout to prevent premature request failures during server processing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@jacek-kupczyk-wenovate jacek-kupczyk-wenovate force-pushed the feat/add_configurable_read_timeout branch from 8a7d2f8 to 055ddad Compare June 19, 2026 16:00
@isasmendiagus

isasmendiagus commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Hi @jacek-kupczyk-wenovate, thanks for this!

I think the real issue is that OkHttp applies a default readTimeout of 10s even when you only set callTimeout, so on longer scans the call dies at ~10s while the server is still processing, even with callTimeout=120s. I reproduced it locally and readTimeout=0 fixes it (and callTimeout still protects us when read is disabled).

So 👍 on the default change.

Could we drop the --read-timeout CLI flag though and keep just the default fix? That's what actually solves the issue, and since --timeout already gives a hard ceiling the extra flag feels like an unnecessary knob. Happy to keep it if you have a use case in mind.

@jacek-kupczyk-wenovate

Copy link
Copy Markdown
Author

Hi @isasmendiagus

Thank you for the quick response. We don't actually need the read timeout to be configurable, so setting it to 0 should be sufficient. I agree that the --read-timeout CLI flag is an unnecessary knob in this case. I'll update my PR and add a PR message with some additional details.

@jacek-kupczyk-wenovate jacek-kupczyk-wenovate force-pushed the feat/add_configurable_read_timeout branch from 055ddad to 5db8466 Compare June 22, 2026 19:55
@jacek-kupczyk-wenovate jacek-kupczyk-wenovate changed the title feat: Add configurable read timeout Fix: Disable OkHttp read timeout to prevent premature timeouts Jun 22, 2026
@jacek-kupczyk-wenovate jacek-kupczyk-wenovate force-pushed the feat/add_configurable_read_timeout branch from 5db8466 to 2ffba3f Compare June 22, 2026 20:02
@jacek-kupczyk-wenovate jacek-kupczyk-wenovate marked this pull request as ready for review June 22, 2026 20:04
@jacek-kupczyk-wenovate

Copy link
Copy Markdown
Author

@isasmendiagus I applied the changes as discussed. Please review PR again.

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.

2 participants