With simple usage just as with the express example on the README, the express listener is still running from the return statement in the snippet from node_modules/express/lib/application.js below:
app.listen = function listen() {
var server = http.createServer(this);
return server.listen.apply(server, arguments);
};
I've verified that I only have one instance of express listening, by putting an unmistakeable console.log just before that return statement above.
$ node --version
v14.11.0
$ npm ls express
redacted-package
└── express@4.17.1
The problem is:
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● TCPSERVERWRAP
at Function.listen (../node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (index.ts:1195:32)
The app that won't stop (only the relevant parts are pasted):
import express from "express";
const app = express();
const server: Server = app.listen(port, () =>
logger.info(`Listening on port ${port}...`),
);
module.exports = server;
import { createHttpTerminator, HttpTerminator } from 'http-terminator';
let server: Server;
let httpTerminator: HttpTerminator;
describe("/", () => {
beforeEach(async () => {
server = require("../../../index"); // This is the file shown in the block above
httpTerminator = createHttpTerminator({
gracefulTerminationTimeout: 0,
server,
});
void (await redactedPromiseReturner());
});
afterEach(async () => {
void (await httpTerminator.terminate());
});
What are some troubleshooting tips?
With simple usage just as with the
expressexample on theREADME, theexpresslistener is still running from thereturnstatement in the snippet fromnode_modules/express/lib/application.jsbelow:I've verified that I only have one instance of
expresslistening, by putting an unmistakeableconsole.logjust before thatreturnstatement above.The problem is:
Jest has detected the following 1 open handle potentially keeping Jest from exiting: ● TCPSERVERWRAP at Function.listen (../node_modules/express/lib/application.js:618:24) at Object.<anonymous> (index.ts:1195:32)The app that won't stop (only the relevant parts are pasted):
What are some troubleshooting tips?