Fail Faster
For a long time I have heard complaints that Xdebug, with its debugger enabled, slows down applications, even if there is no IDE listening.
I have never been able to reproduce this, as on Linux (and macOS), TCP connections to a localhost ports fail immediately if that port is not open.
Xdebug waits for up to 200ms when making a debug connection. This is configurable with the xdebug.connect_timeout_ms setting.
But if there is nothing listening, there should not be any delay, as it ought to be an immediate error.
I wrote a comment in an issue from 2024:
The error message
ERR: Time-out connecting to debugging client, waited: 200 ms.indicates that your network stack doesn't immediately reject the connection if it can't be made. That's usually due to a (misconfigured) firewall.
It turns out, that it is not a firewall, but that Windows itself behaves bad here. Instead of failing immediately, it does retry sending TCP SYN packets to try to establish a connection. This is pointless on the local loopback interface, as network packets cannot get lost.
Through a post by Daniel Stenberg on Mastodon, I found out the cause, and a solution.
He explains how it affects curl's Happy Eyeballs algorithm in a blog post from 2024. Although Xdebug does not use Happy Eyeballs, the underlying problem is the same.
Last week, Marcel Jamin wrote to the curl mailing list, with a solution. This solution disables the retry mechanism to establish a connection. And in turn that means, that there is no longer a delay on Windows either.
I have today merged a pull request for Xdebug which implements this solution. The patch is part of the upcoming Xdebug 3.6 release.
Likes
❤️ Dennis Koch
❤️ mattsches
Comments
@blog I think it probably is a firewall issue really, unless Windows is ignoring the RST packets that tell it nothing is listening.
That's what happens on linux - the SYN is sent and gets an RST and that is reported as a connection failure with EPORTUNREACH but if you firewall loopback so it doesn't get the RST then you get the Windows behaviour of it retrying SYN packets.
There's nothing special about the loopback handling in linux.
Life Line
Merged pull request #1100
Fixed issue #2267: Application slow when debugger is not listening on…
I walked 3.0km in 1h10m24s
Is there somebody who runs PHP on native windows (with Xdebug) and can run a simple script for me?
It must be in a file (`test.php`):
```
<?php
echo microtime(true), "\n";
xdebug_connect_to_client();
echo microtime(true), "\n";
```And run like:
php -dxdebug.log_level=11 -dxdebug.log=c:\temp\xdebug-i.log -dxdebug.client_host=localhost -dxdebug.client_port=9111 -dxdebug.mode=debug c:\temp\test.php
With the port 9111 not open.
Would love to see the output and log file (in a DM).
I walked 5.5km in 55m06s
@harry_wood This is this list of 100 Go-mistakes that I was talking about: https://100go.co/
Updated a crossing
I walked 2.1km in 20m08s
Enjoying my afternoon and evening out at Lords for some cricket!
I walked 3.2km in 38m54s
I walked 9.1km in 1h34m28s
Updated a gate
Updated a bakery shop
Updated a convenience shop
I walked 8.1km in 1h32m18s
I walked 5.6km in 59m13s
Updated a restaurant and a cafe; Confirmed 2 restaurants and a cafe
I walked 6.7km in 1h8m27s
I walked 4.7km in 50m02s
I got myself a sheet of Sun-safe filter material, and McGuyvered a pop-up filter for my lens.
The first attempt sort of worked, but I didn't get the filter 100% straight. Luckily I have more material.
But this is sort of my first attempt, and a few sunspots are clearly visible on the right of the image.
Warning: Never look at the Sun without protection!
Go with 2026.02
Improve error messages for `timelib_duration_create_from_iso8601strin…
Fix overflow in the nanosecond carry in `timelib_duration_div_static()`
Consistently use `stdint.h` types for `timelib_duration`
Created 2 recyclings



Shortlink
This article has a short URL available: https://drck.me/fail-faster-kbh