Newly created objects are not immediately available

We developed a middleware to make calls to the HubSpot API along with functional tests. For testing, when creating a new object, we had to implement PHP’s `sleep()` method to allow time for HubSpot’s collection response to include the new object. We had to keep increasing the `sleep()` time for the tests to finish without errors.

Example of failed tests.

  • Create Contact Object Test (success)
  • Don’t use `sleep()` method
  • Get collection by Contact ID test (fail)
  • Get collection by email address test (fail)
  • Get single contact ID test (fail)

Example of successful tests.

  • Create Contact Object Test (success)
  • `sleep(15)`; 15 seconds. we had to keep increasing in order to get success on a regular basis.
  • Get collection by Contact ID test (success)
  • Get collection by email address test (success)
  • Get single contact ID test (success)

Is this a HubSpot caching issue? Is there a way to force HubSpot to bust the cache so the new object is available?

Hi, @KFoubert. Thanks for your question.

When you create or update an object, that change is immediately committed to the primary data store. However, it might take a short amount of time to propagate that change to all the secondary data stores that respond to read requests. Unfortunately, there’s no way to ‘bust the cache’ or otherwise force HubSpot to propagate changes immediately.

Your approach of using a sleep is a suitable approach. Hey, @MatthiasWeber @stefen, do you have any additional suggestions for @KFoubert?

Thank you for taking a look! — Jaycee