Sockets hanging with node16
See original GitHub issueWhat is your Scenario?
Web app that makes client side fetch to two API endpoints, both on localhost but one is not running, so doesn’t accept connections (which is fine, error is handled and app is functional)
Running tests with node v14.x is just fine, after switching to v16 tests start to break after a while
Symptoms observed in chrome network tools are that calls to both API endpoints are in pending
state
After a while of debugging I’ve noticed that testcafe’s behaviour for requests that are supposed to fail (since there’s no server listening) is much different in node16 than node14 Looking at network tools: Node v16
Node v14
As you can see, in node 14 such request fails instantly, as it should. With node 16 the request is pending
.
I cannot prepare a sample that reproduces my exact problem (where after a while both /api
calls are constantly pending
in subsequent tests) but I’m assuming maybe sockets are not properly closed in my case and just saturate some system limits
What is the Current behavior?
Fetch requests that are supposed to fail are pending
What is the Expected behavior?
Requests should fail immediately if there’s no server listening on the other end
What is your public website URL? (or attach your complete example)
https://github.com/andrzej-kodify/testcafe-hanging-sockets Launch server
npm run serve
Launch tests with node 16
npm run test:debug
and look in chrome network tools on how failed requests behave. Tests are passing, no JS errors.
Do the same with node 14 - requests fail immediately, and there’s a JS error (as fetch exception is not handled)
What is your TestCafe test code?
// https://github.com/andrzej-kodify/testcafe-hanging-sockets
const { Selector } = require("testcafe");
fixture('Fixture');
for (let i=0; i<1000; i++) {
test(`Test ${i}`, async (browser) => {
await browser.navigateTo('http://localhost:3666/');
await browser.expect(Selector('#response').innerText).match(/[0-9]+/);
});
}
Your complete configuration file
No response
Your complete test report
No response
Screenshots
No response
Steps to Reproduce
TestCafe version
1.19.0
Node.js version
version v14.18.1 runs fine, versions 16+ (e.g. v16.15.1) fail
Command-line arguments
chrome
Browser name(s) and version(s)
Version 102.0.5005.61 (Official Build) (arm64)
Platform(s) and version(s)
macOS 12.4
Other
I’ve made silly workaround by applying this patch in my actual tests https://github.com/andrzej-kodify/testcafe-hanging-sockets/blob/main/testcafe-hammerhead%2B24.5.16.patch
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:9
Top GitHub Comments
Thank you for the additional information! We increased the frequency level for this issue, which will give it higher priority during our future planning.
Hi @andrzej-kodify
Thank you for the shared example. I’ve reproduced the issue.