mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 18:20:59 -05:00
tests(test-setup): ensure shutdown hooks get run
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
4746c30c26
commit
bbf7209c27
3 changed files with 3 additions and 7 deletions
|
@ -79,4 +79,5 @@ export async function setupApp(
|
||||||
const { httpAdapter } = app.get(HttpAdapterHost);
|
const { httpAdapter } = app.get(HttpAdapterHost);
|
||||||
app.useGlobalFilters(new ErrorExceptionMapping(httpAdapter));
|
app.useGlobalFilters(new ErrorExceptionMapping(httpAdapter));
|
||||||
app.useWebSocketAdapter(new WsAdapter(app));
|
app.useWebSocketAdapter(new WsAdapter(app));
|
||||||
|
app.enableShutdownHooks();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,6 @@ async function bootstrap(): Promise<void> {
|
||||||
// Setup code must be added there!
|
// Setup code must be added there!
|
||||||
await setupApp(app, appConfig, authConfig, mediaConfig, logger);
|
await setupApp(app, appConfig, authConfig, mediaConfig, logger);
|
||||||
|
|
||||||
/**
|
|
||||||
* enableShutdownHooks consumes memory by starting listeners. In cases where you are running multiple Nest apps in a
|
|
||||||
* single Node process (e.g., when running parallel tests with Jest), Node may complain about excessive listener processes.
|
|
||||||
* For this reason, enableShutdownHooks is not enabled in the tests.
|
|
||||||
*/
|
|
||||||
app.enableShutdownHooks();
|
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
await app.listen(appConfig.port);
|
await app.listen(appConfig.port);
|
||||||
logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap');
|
logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap');
|
||||||
|
|
|
@ -89,6 +89,7 @@ export class TestSetup {
|
||||||
}
|
}
|
||||||
if (connectionOptions.type === 'sqlite') {
|
if (connectionOptions.type === 'sqlite') {
|
||||||
// Bail out early, as SQLite runs from memory anyway
|
// Bail out early, as SQLite runs from memory anyway
|
||||||
|
await this.app.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (appConnection.isConnected) {
|
if (appConnection.isConnected) {
|
||||||
|
@ -106,6 +107,7 @@ export class TestSetup {
|
||||||
await connection.close();
|
await connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await this.app.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue