Closed student020341 closed 1 year ago
The issue was the listeners (including the one that handles cleanup) are removed before the close
event is fired, simply swapping these 2 lines here or just removing the removeAllListeners()
call should resolve the issue.
I still saw the issue if I swapped the 2 lines, but removing this.#ws.removeAllListeners();
did appear to fix the issue. Any potential repercussions of not removing those listeners?
Not much, since it's only storing arrays of listeners. Nothing is kept alive if the emitter goes out of scope
Here is a quick test file that hangs with mocha. I ran the "why-is-node-running" library at one point and I think the output from that suggests the websocket is not closing.
Here's the output from "why-is-node-running"
I ran an identical test with the postgres client which showed similar behavior if the close call was omitted.