test: fix flaky timeout-request body and headers tests
fix the flaky test-http-server-request-timeout-delayed-body
and test-http-server-request-timeout-delayed-headers
tests which sometimes fail on slow systems. This happened to me today on the raspberry pi CI, and I could reproduce this locally by running /tools/test.py -j250 --repeat=1000 test/parallel/test-http-server-request-timeout-delayed-body.js
. I could not reproduce the issue after my fix.
The reason, I believe, is that sometimes it takes more than a second for the request to "reach" the server. I've changed the tests to delay the body/headers sending to only happen when we're sure that a connection was made with the server.
EDIT: Also added the same fix to:
test/parallel/test-http-server-request-timeout-interrupted-body.js
test/parallel/test-http-server-request-timeout-interrupted-headers.js
test/parallel/test-http-server-request-timeout-upgrade.js