Socket hang up / ECONNRESET errors with Node.js 20.x
bkimminich opened this issue · comments
With Node.js 20.x previously working and otherwise unchanged Frisby tests start failing with either
Summary of all failing tests
...
FetchError: request to http://localhost:3000/rest/user/login failed, reason: socket hang up
at ClientRequest.<anonymous> (node_modules/node-fetch/lib/index.js:1501:11)
(Example: https://github.com/juice-shop/juice-shop/actions/runs/6539449747/job/17758607028#step:6:387)
or
Summary of all failing tests
...
FetchError: request to http://localhost:3000/rest/user/login failed, reason: read ECONNRESET
at ClientRequest.<anonymous> (node_modules/node-fetch/lib/index.js:1501:11)
(Example: https://github.com/juice-shop/juice-shop/actions/runs/6539449747/job/17758607313#step:6:579)
errors.
This is very likely related to changes in node-fetch
and/or Node.js internal connection handling. This behavior is fully reproducible and deterministic. It is not limited to specific test cases, as disabling or removing the failing test will simply make another test fail from the same error. This can be repeated until no more tests are left... (which solves the problem, but not in a good way... 🤣)
For reproduction steps of the above failing suites, please see juice-shop/juice-shop#2068.
Likely related issues we identified are
- node-fetch/node-fetch#1735
- nodejs/node#47130
but none of the workarounds proposed (like changing connection timeouts) had any effect for our case in OWASP Juice Shop.
❓Can other Frisby.js users confirm the behavior? If Node.js 20.x works fine for you, could you please provide a link to your working Frisby.js setup with Node.js 20.x?
I guess this relates to node-fetch/node-fetch#1765 which is fixed in node-fetch@2.6.13.
Just updating node-fetch does not remediate the issue, at least it didn't for me. Only closing the connection did fix it permanently. And funny enough it wasn't enough to add the header via the global setup configuration. Not sure if there's some timing/race condition happening, but the the only stable test executions I was able to get, was from my fork... 🤷♂️