algoliasearch-client-ruby icon indicating copy to clipboard operation
algoliasearch-client-ruby copied to clipboard

Client allows endless loops if there is a network issue

Open kaspergrubbe opened this issue 5 years ago • 4 comments

  • Algolia Client Version: Only tested 1.26.0
  • Language Version: Not relevant.

Description

This is basically an endless loop:

https://github.com/algolia/algoliasearch-client-ruby/blob/55e2fb916eb147e51532fd08bdb0d75a58f12ce1/lib/algolia/client.rb#L494-L511

There should be some retry logic, and if enough fails it should throw an error.

kaspergrubbe avatar May 31 '20 00:05 kaspergrubbe

Related: when perform a save_objects! with an empty batch, the taskID returned from the engine never resolves, resulting in this loop running forever.

client = ::Algolia::Search::Client.create_with_config(
::Algolia::Search::Config.new(
application_id: ENV['ALGOLIA_APP_ID'],
api_key: ENV['ALGOLIA_ADMIN_API_KEY'],
batch_size: ENV['ALGOLIA_BATCH_SIZE']
)
)

index = client.init_index('test-index-name')
index.save_objects!([]) # Hangs forever

We'll need to come up with a proper way to break here after x loops to prevent the infinite loop. I'll discuss this internally to see what we want to do about it.

DevinCodes avatar Sep 27 '21 08:09 DevinCodes

thanks for looking into the issue : )

berniechiu avatar Sep 30 '21 05:09 berniechiu

This code still seem to be causing endless loops when there's issues on Algolias servers.

https://status.algolia.com/incidents/4367

kaspergrubbe avatar Jul 13 '23 11:07 kaspergrubbe

@chuckmeyer reached out to me on Twitter, and pointed me to this PR: https://github.com/algolia/algoliasearch-client-ruby/pull/487

kaspergrubbe avatar Jul 17 '23 13:07 kaspergrubbe