Skip to content

Conversation

@brunoluigi
Copy link

What this does

  • Add POST method to Faraday retry configuration (not retried by default)
  • Add tests verifying retry behavior for both Faraday 1.x and 2.x code paths
  • Add expected_url_for helper for URL assertions in error tests
  • Reduce retry intervals in test configuration for faster test execution

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
    • For provider changes: Re-recorded VCR cassettes with bundle exec rake vcr:record[provider_name]
    • All tests pass: bundle exec rspec
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

Related issues

Fixes #417

- Add POST method to Faraday retry configuration (not retried by default)
- Add tests verifying retry behavior for both Faraday 1.x and 2.x code paths
- Add `expected_url_for` helper for URL assertions in error tests
- Reduce retry intervals in test configuration for faster test execution
RSpec.describe RubyLLM::Chat do
include_context 'with configured RubyLLM'

before do
Copy link
Author

Choose a reason for hiding this comment

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

I've done this since those tests running with retry enable were changing the VCR recorded requests and I wasn't sure if it was supposed to happen, need some help here =)

config.retry_interval = 1
config.retry_backoff_factor = 3
config.retry_interval_randomness = 0.5
config.max_retries = 2
Copy link
Author

Choose a reason for hiding this comment

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

Once retry is enabled the tests at spec/ruby_llm/chat_streaming_spec.rb:57 starts to wait between retries and with the current settings it takes a lot of time so I adjusted to something more adequate for test environments.

One question is, should the faraday-retry middleware actually wait in the test environment or it could be set to simply skip the waiting and retry right away?

end.to raise_error(expected_error_for(provider))
end

it 'retries the request' do
Copy link
Author

Choose a reason for hiding this comment

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

Inspired by the test that @AlexVPopov suggested in the issue #417

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.

[BUG] RubyLLM not retrying POST requests

1 participant