Skip to content

Fix flaky test test-http-pipeline-flood

rebase of nodejs/node-v0.x-archive#25870 Fixes nodejs/node-v0.x-archive#25732 and nodejs/node-v0.x-archive#25709

So, some background. This test looks to test a feature to prevent a DoS vulnerability. Essentially once native socket write buffers have filled up, the http parser should cork the read stream. (requests in data which has already been read will still be processed)

Current test

  • sets up a http server, with a timeout which destroys the connection after 200ms of inactivity.
  • creates a child which continuously fires requests and does not read responses.
  • On exit asserts that:
    • Inactivity timeout has fired
    • 250 requests have been processed

    • The child process terminated

Issues:

  • Flaky on windows because of very small socket buffers (write buffers fill after only a few responses), depending on timing this means that only ~40 requests will get processed
  • Does not make much sense to assert number of requests greater than a threshold when testing a DoS prevention feature.
  • If feature under test not working, the test case runs until program runs out of memory

New test

  • Set up server without inactivity timer
  • Create child process like before, but with timeout to kill itself after specified amount of time
  • When server sends response, check if native buffer filled (res.write() returns false). On first time:
    • Add listener for data events on the socket which asserts false (backlog logic should have corked the stream so it should never be called)

Merge request reports

Loading