Add connect-timeout to Matrix webhook calls (#77)
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lhz7pGMaoTfL5sdYS5XiKv
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user