Apple notification forward never blocks our own processing

The APPLE_PROXY_HOST forward runs before the notice is stored, with no
timeout and no error handling. When the target is down, every notice
throws, Apple gets a 500 and nothing is stored or sent to AppsFlyer.
cdlbackend (analytics.mapo.la/webhooks/13) and dmvbackend (/42) have
been in that state since 2025-06-16.

Now the forward waits at most proxy_timeout seconds (APPLE_PROXY_TIMEOUT,
default 5) and a failure is only logged as a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AIDev Bot
2026-11-17 07:04:57 +00:00
co-authored by Claude Opus 5.5
parent d37045d3e3
commit 25d98a4ee3
3 changed files with 20 additions and 1 deletions
+4
View File
@@ -23,4 +23,8 @@ return [
// 'did_change_renewal_status' => \App\Jobs\AppstoreNotifications\HandleDidChangeRenewalStatus::class,
],
'proxy_host' => env('APPLE_PROXY_HOST'),
/*
* Seconds to wait for the proxy_host before giving up (the forward never blocks our own processing).
*/
'proxy_timeout' => env('APPLE_PROXY_TIMEOUT', 5),
];
+7
View File
@@ -23,6 +23,9 @@ class ProxyHelper {
private $addQuery;
//Timeout in seconds (connect and total), none if empty
private $timeout;
//If needed add cookies support with:
// - PendingRequest->withCookies
// - Request->hasCookie
@@ -53,6 +56,8 @@ class ProxyHelper {
public function preserveQuery($preserve){ $this->addQuery = $preserve; return $this; }
public function withTimeout($seconds){ $this->timeout = $seconds; return $this; }
public function getResponse($url){
$info = $this->getRequestInfo();
@@ -60,6 +65,8 @@ class ProxyHelper {
$http = $this->createHttp($info['type']);
$http = $this->setAuth($http, $info['token']);
$http = $this->setHeaders($http);
if($this->timeout)
$http = $http->timeout((int)$this->timeout)->withOptions(['connect_timeout' => (int)$this->timeout]);
if($this->addQuery && $info['query'])
$url = $url.'?'.http_build_query($info['query']);
+9 -1
View File
@@ -4,6 +4,7 @@ namespace Appvise\AppStoreNotifications;
use Appvise\AppStoreNotifications\ProxyHelperFacade;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Appvise\AppStoreNotifications\Model\NotificationType;
use Appvise\AppStoreNotifications\Model\AppleNotification;
use Appvise\AppStoreNotifications\Exceptions\WebhookFailed;
@@ -15,7 +16,14 @@ class WebhooksController
{
$proxy_host = config('appstore-server-notifications.proxy_host');
if (!empty($proxy_host)) {
ProxyHelperFacade::CreateProxy($request)->toUrl($proxy_host);
// The forward must never stop our own processing: short timeout, errors only logged.
try {
ProxyHelperFacade::CreateProxy($request)
->withTimeout(config('appstore-server-notifications.proxy_timeout', 5))
->toUrl($proxy_host);
} catch (\Throwable $e) {
Log::warning("Apple notification forward to {$proxy_host} failed: " . $e->getMessage());
}
}
$jobConfigKey = NotificationType::{$request->input('notification_type')}();