这是indexloc提供的服务,不要输入任何密码
Skip to content

Still get 429 errors with LeakyBucketExecutionPolicy #1200

@TimSirmovics

Description

@TimSirmovics

I am setting ShopifyService.SetGlobalExecutionPolicy(new LeakyBucketExecutionPolicy()); before executing any Shopify calls.
My understanding is that this should avoid any 429 errors, however I still get them sometimes when trying to update inventory.

I have noted this error when looping through 171, 182 and 186 items.
I am not sure how far through the loop it got before the error.

The code is essentially below:

foreach (var item in items)
{
    var inventoryLevel = new InventoryLevel { InventoryItemId = item.InventoryItemId, LocationId = itemLocationId, Available = item.Available };
    await _inventoryLevelService.SetAsync(inventoryLevel);
}

And the relevant section of the stack trace:

---> ShopifySharp.ShopifyRateLimitException: (429 Too Many Requests) Exceeded 2 calls per second for api client. Reduce request rates to resume uninterrupted service.
   at ShopifySharp.ShopifyService.CheckResponseExceptions(String requestInfo, HttpResponseMessage response, String rawResponse)
   at ShopifySharp.ShopifyService.<>c__DisplayClass27_0.<<ExecuteRequestCoreAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at ShopifySharp.DefaultRequestExecutionPolicy.Run[T](CloneableRequestMessage baseRequestMessage, ExecuteRequestAsync`1 executeRequestAsync, CancellationToken cancellationToken, Nullable`1 graphqlQueryCost)
   at ShopifySharp.ShopifyService.ExecuteRequestCoreAsync(RequestUri uri, HttpMethod method, HttpContent content, Dictionary`2 headers, Nullable`1 graphqlQueryCost, CancellationToken cancellationToken)
   at ShopifySharp.ShopifyService.ExecuteRequestCoreAsync[T](RequestUri uri, HttpMethod method, CancellationToken cancellationToken, HttpContent content, Dictionary`2 headers, String rootElement, Nullable`1 graphqlQueryCost, Nullable`1 dateParseHandlingOverride)
   at ShopifySharp.ShopifyService.ExecuteRequestAsync[T](RequestUri uri, HttpMethod method, CancellationToken cancellationToken, HttpContent content, String rootElement, Dictionary`2 headers)
   at ShopifySharp.InventoryLevelService.SetAsync(InventoryLevel updatedInventoryLevel, Boolean disconnectIfNecessary, CancellationToken cancellationToken)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions