mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): Stop using unbound calls to stopProcess (no-changelog) (#5456)
This commit is contained in:
committed by
GitHub
parent
d266401ed8
commit
9a331ec7b6
@@ -1,4 +1,5 @@
|
||||
import { Command } from '@oclif/command';
|
||||
import { ExitError } from '@oclif/errors';
|
||||
import type { INodeTypes } from 'n8n-workflow';
|
||||
import { LoggerProxy, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow';
|
||||
import type { IUserSettings } from 'n8n-core';
|
||||
@@ -35,8 +36,8 @@ export abstract class BaseCommand extends Command {
|
||||
async init(): Promise<void> {
|
||||
await initErrorHandling();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
this.stopProcess = this.stopProcess.bind(this);
|
||||
process.once('SIGTERM', async () => this.stopProcess());
|
||||
process.once('SIGINT', async () => this.stopProcess());
|
||||
|
||||
// Make sure the settings exist
|
||||
this.userSettings = await UserSettings.prepareUserSettings();
|
||||
@@ -88,7 +89,11 @@ export abstract class BaseCommand extends Command {
|
||||
|
||||
async finally(error: Error | undefined) {
|
||||
if (inTest || this.id === 'start') return;
|
||||
if (Db.isInitialized) await Db.connection.destroy();
|
||||
this.exit(error ? 1 : 0);
|
||||
if (Db.isInitialized) {
|
||||
await sleep(100); // give any in-flight query some time to finish
|
||||
await Db.connection.destroy();
|
||||
}
|
||||
const exitCode = error instanceof ExitError ? error.oclif.exit : error ? 1 : 0;
|
||||
this.exit(exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user