Skip to content

ci: Properly handle open connections after the tests finish #2185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions integration/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const ParseServer = require('parse-server').default;
const CustomAuth = require('./CustomAuth');
const sleep = require('./sleep');

Check warning on line 8 in integration/test/helper.js

View workflow job for this annotation

GitHub Actions / Lint

'sleep' is assigned a value but never used
const { TestUtils } = require('parse-server');
const Parse = require('../../node');
const fs = require('fs');
Expand Down Expand Up @@ -93,16 +93,6 @@
};

const openConnections = {};
const destroyAliveConnections = function () {
for (const socketId in openConnections) {
try {
openConnections[socketId].destroy();
delete openConnections[socketId];
} catch (e) {
/* */
}
}
};
let parseServer;
let server;

Expand Down Expand Up @@ -175,17 +165,18 @@

afterEach(async () => {
await Parse.User.logOut();
// Connection close events are not immediate on node 10+... wait a bit
await sleep(0);
if (Object.keys(openConnections).length > 0) {
console.warn('There were open connections to the server left after the test finished');
}
Parse.Storage._clear();
await TestUtils.destroyAllDataPermanently(true);
destroyAliveConnections();
if (didChangeConfiguration) {
await reconfigureServer();
}
});

afterAll(() => {
// Jasmine process counts as one open connection
if (Object.keys(openConnections).length > 1) {
console.warn('There were open connections to the server left after the test finished');
}
});

module.exports = { twitterAuthData };
Loading