Skip to content

Fix waitForData crash when the socket is disconnected#33

Merged
GrahamCampbell merged 1 commit into
1.9from
fix-wait-for-data-disconnected
Jul 6, 2026
Merged

Fix waitForData crash when the socket is disconnected#33
GrahamCampbell merged 1 commit into
1.9from
fix-wait-for-data-disconnected

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Member

The waitForData() method added in 1.9.0 calls stream_select() without checking that the socket resource still exists. When the peer closes the connection, receive() detects EOF and disconnects the socket, setting the underlying resource to null, so a subsequent waitForData() call passes null to stream_select(), which throws a ValueError on PHP 8 that the @ suppression cannot catch. This surfaced as a flaky teardown failure in chrome-php/chrome, where Chrome 140 closes the DevTools WebSocket during shutdown while the client is still waiting for a response. This change makes AbstractSocket::waitForData() return null when the socket is gone, matching the documented error contract of that method, and makes Client::waitForData() check the connection state first, consistent with sendData() and receive().

@GrahamCampbell GrahamCampbell merged commit ae230b7 into 1.9 Jul 6, 2026
20 checks passed
@GrahamCampbell GrahamCampbell deleted the fix-wait-for-data-disconnected branch July 6, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant