We are running sylius/adyen-plugin (version: 2.0.5 on Sylius version: 2.2.5).
We sometimes hit a race condition on AUTHORISATION webhooks: Adyen delivers the webhook almost immediately after payment completion, sometimes before the local AdyenReference row has been committed to the database.
Current behavior:
ProcessNotificationsAction::__invoke resolves and dispatches the command synchronously inside the HTTP request:
try {
$command = $this->notificationCommandResolver->resolve($paymentMethodCode, $notificationItem);
$this->messageBus->dispatch($command);
} catch (NoCommandResolvedException) {
$this->logger->error(sprintf(
'Tried to dispatch an unknown command. Notification body: %s',
json_encode($notificationItem, JSON_PARTIAL_OUTPUT_ON_ERROR),
));
}
The failure point seems to be the resolve step: PaymentNotificationResolver::getPayment calls AdyenReferenceRepository::getOneByCodeAndReference, which throws NoResultException when the AdyenReference row is not yet committed. This propagates as NoCommandResolvedException.
Example of the logged error we observe:
Tried to dispatch an unknown command. Notification body: {"eventCode":"authorisation","merchantReference":"XXXXX","pspReference":"XXXXX","originalReference":null,...}
Questions
-
Would it be safe to defer the entire resolve + dispatch block to a Messenger message — acknowledging the webhook immediately and performing the resolution in a handler that can be retried on failure ?
-
Is there a reason the plugin resolves and dispatches the command inline in the HTTP request rather than deferring the entire block to a message bus (which the application could configure as synchronous or asynchronous) ?
-
Are there webhook event types for which async processing would be problematic ?
Thank you.
We are running sylius/adyen-plugin (version: 2.0.5 on Sylius version: 2.2.5).
We sometimes hit a race condition on AUTHORISATION webhooks: Adyen delivers the webhook almost immediately after payment completion, sometimes before the local AdyenReference row has been committed to the database.
Current behavior:
ProcessNotificationsAction::__invoke resolves and dispatches the command synchronously inside the HTTP request:
The failure point seems to be the resolve step: PaymentNotificationResolver::getPayment calls AdyenReferenceRepository::getOneByCodeAndReference, which throws NoResultException when the AdyenReference row is not yet committed. This propagates as NoCommandResolvedException.
Example of the logged error we observe:
Tried to dispatch an unknown command. Notification body:
{"eventCode":"authorisation","merchantReference":"XXXXX","pspReference":"XXXXX","originalReference":null,...}Questions
Would it be safe to defer the entire resolve + dispatch block to a Messenger message — acknowledging the webhook immediately and performing the resolution in a handler that can be retried on failure ?
Is there a reason the plugin resolves and dispatches the command inline in the HTTP request rather than deferring the entire block to a message bus (which the application could configure as synchronous or asynchronous) ?
Are there webhook event types for which async processing would be problematic ?
Thank you.