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
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
Only test with 8.2 and later on master with Xdebug CI
Merge branch 'xdebug_3_5'
Remove expliciy path from Xdebug CI
If you're wondering why the @Xdebug issue tracker is unavailable, I can conclusively say that it's another bout of LLM scrapers.
I walked 1.3km in 14m45s
Created 18 benches and a grave; Updated 3 benches, a tree, and a waste_basket
I walked 6.1km in 3h9m07s
Updated a vacant business
Updated a bar
I walked 1.6km in 18m00s
Updated a pub
I walked 3.4km in 54m56s
I walked 1.9km in 23m48s
Updated a pub
I walked 3.4km in 22m41s
Updated a restaurant
I walked 7.2km in 3h16m35s
I walked 9.5km in 2h0m35s
Ribbit!
I heard this little one way before I could see it. It is so well camouflaged!
Created 3 entrances, 3 emergency entrances, and a main entrance; Confirmed a childcare
I walked 6.8km in 1h16m53s
Updated a restaurant
I walked 10.0km in 1h43m36s
I had a good run at Polderprikker today!
#Polderprikker nummer 84 • 4810/5000
🟦1000 🟦1000 🟨879 🟩931 🟦1000
https://polderprikker.nl/I'm looking forward to attending the State of the Map OpenStreetMap conference this coming week in Paris.
Will I see you there?


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