Conversation
| $socket = $this->socket; | ||
| $payloadLength = \strlen($payload); | ||
| $totalWrittenBytes = 0; | ||
| $writeDeadline = microtime(true) + self::SOCKET_TIMEOUT_SECONDS; |
There was a problem hiding this comment.
Bug: The fixed 10ms write timeout in writePayload is likely insufficient for large payloads, causing unnecessary fallbacks to the HTTP transport even with a healthy agent.
Severity: MEDIUM
Suggested Fix
Introduce a separate, more generous timeout for the payload writing operation. Alternatively, make the write timeout configurable or calculate it dynamically based on the payload size to ensure sufficient time is allocated for large data transfers without affecting the quick connection timeout.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/Agent/Transport/AgentClient.php#L149
Potential issue: The `AgentClient` uses the same 10ms timeout (`SOCKET_TIMEOUT_SECONDS`)
for both the initial socket connection and for writing the entire payload in
`writePayload`. For large payloads, such as events with attachments, or when the agent
is under load, the non-blocking write operation may require multiple iterations that
collectively take longer than 10ms. This will cause the write to fail and trigger a
fallback to the standard HTTP transport, even if the agent is healthy and capable of
receiving the data. This leads to inefficient transport usage in certain valid
scenarios.
Contributor
Author
There was a problem hiding this comment.
Attachments is a good point, maybe we should have an attachment and non attachment path
stayallive
approved these changes
Apr 28, 2026
This was referenced Apr 30, 2026
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the
AgentClientso that it can receive a fallback client in case the agent is unavailable. The fallback client is constructed through a factory to allow frameworks and other processes to set the necessary information.