Our customer is testing this module and noticed error messages like these:
Smartling\Exceptions\SmartlingApiException: Async operation is not completed after 16 seconds.

Our investigation led us to the ContextUploader, the uploadAndMatchContext method in specific.
What could be causing these time-outs? Is there any way to prevent them aside from increasing the default time-out of 15 seconds?

Comments

bceyssens created an issue. See original summary.

loparev’s picture

Hi bceyssens,

this happens inside Smartling's api-sdk-php lib on upload and match context sync call. What it means is that smartling context api processes context asynchronously and we poll async process 15 seconds and if it's not completed just throw an exception there.

But in your case I do see a lot of `Async operation is not completed after 15s seconds.` log records (from `94e2dcf74` smartling project) but I don't see appropriate HTTP requests to context API for polling async processes. For example, for `2024-06-26 08:08:43.820 - 2024-06-26 08:12:03.370` I see 7 such errors from `reynaers-acc` host but I see no `/context-api/v2/projects/94e2dcf74/processes/...` HTTP requests for that period of time. Could you please confirm you see those requests from your side? Are those requests blocked?

bceyssens’s picture

@loparev,

We still run into these issues today. Correct responses are received, with content like this:

    [processUid] => 3107a0c4-954d-4db5-ac48-ae07f0e8f598
    [processState] => IN_PROGRESS
    [processType] => MATCH_CONTEXT
    [createdDate] => 2025-09-10T14:10:46Z
    [modifiedDate] => 2025-09-10T14:10:46Z
    [result] => Array ...

Until it switches to state COMPLETED, so the functionality works as designed but it sometimes just takes to long. We tried increasing the time-out to 30 seconds, but it still happens to often. I'll try to capture some of the problematic process ID if you can use those the check logs or something?

Is it really necessary to wait for the matching to complete processing? Edit: If I read the code correctly the response is only used to log a message? I assume it's enough to wait for the upload to complete and continue on Drupal's side?

From time to time queue items are building up rapidly because a lot of translations are being requested (campaign season for our client). We already disabled cron processing to not disturb other processes. See https://www.drupal.org/project/tmgmt_smartling/issues/3545995

loparev’s picture

Hi,

Is it really necessary to wait for the matching to complete processing? If I read the code correctly the response is only used to log a message? I assume it's enough to wait for the upload to complete and continue on Drupal's side?

There are 2 upload context calls (with different parameters) that must be done one after another sequentially in ContextUploader::uploadContextBody():

$api->uploadAndMatchContextSync($upload_params_with_matching);
$response = $api->uploadAndMatchContext($upload_params);

This is the main reason I believe.

From time to time queue items are building up rapidly because a lot of translations are being requested (campaign season for our client). We already disabled cron processing to not disturb other processes.

I understand. Yes, processing these queues separately (not by drupal default's cron) is probably the best solution for you for now.

bceyssens’s picture

@loparev,

We've read the code and understand that this is the flow that needs to be followed, but what's the benefit of waiting on the Smartling matching process to finish? In our case we already increased the timeout to 30 seconds, and even then it's sometimes not enough.

Is there other functionality depending on these processes to finish correctly? Or is it only a log that needs to happen on Drupal side?

bceyssens’s picture

Version: 8.x-9.9 » 8.x-9.x-dev

To prevent locking the process: isn't it possible to do the upload, capture the processUuid from contexts/upload-and-match-async and put that in another queue so we can use DelayedRequeueException to "wait" for the process to finish?

loparev’s picture

> but what's the benefit of waiting on the Smartling matching process to finish?

I already answered, there is api call that must be called when previous async operation is done. Seems like me or you are talking about different things.

> isn't it possible to do the upload, capture the processUuid from contexts/upload-and-match-async and put that in another queue so we can use DelayedRequeueException to "wait" for the process to finish?

Sounds like this will cause exactly the same behaviour - you will still get flooded queue (since you have a lot of translation requests going on), it will be just different queue and you will still have other queue processes interruption.

I would need to take a look how to split/enhance the process.

bceyssens’s picture

The only thing I want to prevent are timeouts and errors in our logs. These are caused by uploadAndMatchContextSync because it uses the wait method to check status of the (slow?) matching process on Smartling side.

That's why I would split the functionality up in 2 steps/queues but keep all existing logic, that way we give Smartling the time it needs to finish processing without failing on our side:

  1. trigger uploadAndMatchContext, retrieve the processUid and create a new item in a separate queue
    • queue worker uses DelayedRequeueException instead of waiting in the PHP process itself
    • when process is finished, fetch all information using uploadAndMatchContext again and log messages
    • trigger (improved) uploadContextMissingResources

The major difference it that the waiting part is not done in PHP but in a queue with the correct exceptions, that won't block the queue. Processing of other queue items will continue while waiting for slow ones.

Part of my comment here https://www.drupal.org/project/tmgmt_smartling/issues/3546398 is related to this topic as well:

I think uploading all of these assets one by one also makes the process incredibly slow. Why not use Guzzle http client instead of curl commands directly after which you could easily execute async upload commands for all of those assets: https://docs.guzzlephp.org/en/stable/quickstart.html#concurrent-requests

loparev’s picture

These errors now are logged as warnings thanks to @j_bekaert

loparev’s picture

Status: Active » Fixed

Updated context upload logic (removed "redundant" call): https://git.drupalcode.org/project/tmgmt_smartling/-/merge_requests/41. Now context resources uploading will be handled in a separate ticket.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.