Closed
Description
Unsure if this is an issue in the adapter itself or upstream, but when calling io.close()
, the adapter's .close()
function is never called, so the connection with MongoDB stays up. I suppose this isn't too serious when closing down a server since everything's torn down anyway, but can be annoying in CI.
Problem:
afterAll((done) => {
io.close(done);
});
One would expect this to shut down cleanly, but after the suite's done:
Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 5.166 s, estimated 6 s
Ran all test suites matching /src\/__tests__\/io.test.js/i.
/.../node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:153
throw new Error('Collection method ' + i + ' is synchronous');
^
Error: Collection method watch is synchronous
at NativeCollection.<computed> [as watch] (/.../node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:153:15)
at initChangeStream (/.../node_modules/@socket.io/mongo-adapter/dist/index.js:80:40)
at Timeout._onTimeout (/.../node_modules/@socket.io/mongo-adapter/dist/index.js:99:17)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
error Command failed with exit code 1.
Which isn't great. A workaround is going into the default namespace and tearing down the adapter manually:
afterAll((done) => {
io.close((err) => {
io.of('/').adapter.close();
done(err);
});
});
Would be nice if this weren't necessary (or at least documented somewhere).