From 9702aafacdd69a9de113f8ffd795ece593dc0290 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 11 Sep 2026 14:04:52 -0400 Subject: [PATCH] Add connect-timeout to Matrix webhook calls (#77) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NotificationHelper::fire() set CURLOPT_TIMEOUT (10s total) but no CURLOPT_CONNECTTIMEOUT, so a slow-but-not-hung hookshot endpoint could add up to the full 10s per fire() call — and a single request can call fire() more than once sequentially (e.g. add_comment.php firing mention + comment + watcher notifications back to back), stacking into tens of seconds of added latency on the user-facing response. Added a 3s CURLOPT_CONNECTTIMEOUT so a slow-to-connect endpoint fails fast without needing the full request to time out. Verified the webhook still fires correctly end-to-end against a real local HTTP server after the change. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Lhz7pGMaoTfL5sdYS5XiKv --- helpers/NotificationHelper.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helpers/NotificationHelper.php b/helpers/NotificationHelper.php index 179043f..4ffa01a 100644 --- a/helpers/NotificationHelper.php +++ b/helpers/NotificationHelper.php @@ -20,6 +20,12 @@ class NotificationHelper curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); + // A slow-but-not-fully-hung hookshot endpoint could otherwise add up + // to the full CURLOPT_TIMEOUT per fire() call, and a single request + // can call fire() (via notifyWatchers/sendCommentNotification/etc.) + // more than once sequentially — capping just the connect phase keeps + // that from stacking into tens of seconds of added latency. + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);