Unclosed connections
- Dominant language
- JavaScript
- Stars
- 2k
- Forks
- 87
- PR merge metrics
- No merged PRs in 30d
Description
I use wait-on to wait for a server between restarts:
```js
await waitOn({
resources: [`tcp:${publicIp}:22`],
delay: 5000,
timeout: 60000,
})
```
After completion it seems like connections are not closed completely:
```js
import wtf from 'wtfnode'
[...]
wtf.dump()
```
Outputs a long list:
```
[WTF Node?] open handles:
- File descriptors: (note: stdio always exists)
- fd 2 (tty) (stdio)
- fd 1 (tty) (stdio)
- Sockets:
- 172.30.0.2:50814 -> undefined:undefined
- Listeners:
- connect: (anonymous) @ /home/workspace/infra/node_modules/.pnpm/wait-on@5.2.0/node_modules/wait-on/lib/wait-on.js:352
- 172.30.0.2:50816 -> undefined:undefined
- Listeners:
- connect: (anonymous) @ /home/workspace/infra/node_modules/.pnpm/wait-on@5.2.0/node_modules/wait-on/lib/wait-on.js:352
[...]
```
Where the line 352 matches [v5.2.0/lib/wait-on.js#L352](https://github.com/jeffbski/wait-on/blob/v5.2.0/lib/wait-on.js#L352). I've tried with `destroy`:
```js
.on('connect', () => {
output(` TCP connection successful to host:${host} port:${port}`);
conn.end();
conn.destroy();
resolve(true);
});
```
It helps (not tested with error/timeout), but I'm not sure that this is the way to go. May be it's something not well documented, because other people [experience this too](https://stackoverflow.com/questions/9191587/how-to-disconnect-from-tcp-socket-in-nodejs#comment49557694_9195645).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.