mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(core): Fix shutdown if terminating before hooks are initialized (#8047)
If the app receives termination signal before hooks have been initialised, the would be objet is undefined error. This PR fixes that.
This commit is contained in:
parent
2689c37e87
commit
6ae2f5efea
|
@ -26,7 +26,7 @@ import { WorkflowHistoryManager } from '@/workflows/workflowHistory/workflowHist
|
|||
export abstract class BaseCommand extends Command {
|
||||
protected logger = Container.get(Logger);
|
||||
|
||||
protected externalHooks: IExternalHooksClass;
|
||||
protected externalHooks?: IExternalHooksClass;
|
||||
|
||||
protected nodeTypes: NodeTypes;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ export class Start extends BaseCommand {
|
|||
// Stop with trying to activate workflows that could not be activated
|
||||
this.activeWorkflowRunner.removeAllQueuedWorkflowActivations();
|
||||
|
||||
await this.externalHooks.run('n8n.stop', []);
|
||||
await this.externalHooks?.run('n8n.stop', []);
|
||||
|
||||
setTimeout(async () => {
|
||||
// In case that something goes wrong with shutdown we
|
||||
|
|
|
@ -39,7 +39,7 @@ export class Webhook extends BaseCommand {
|
|||
this.logger.info('\nStopping n8n...');
|
||||
|
||||
try {
|
||||
await this.externalHooks.run('n8n.stop', []);
|
||||
await this.externalHooks?.run('n8n.stop', []);
|
||||
|
||||
setTimeout(async () => {
|
||||
// In case that something goes wrong with shutdown we
|
||||
|
|
|
@ -79,7 +79,7 @@ export class Worker extends BaseCommand {
|
|||
await Worker.jobQueue.pause(true);
|
||||
|
||||
try {
|
||||
await this.externalHooks.run('n8n.stop', []);
|
||||
await this.externalHooks?.run('n8n.stop', []);
|
||||
|
||||
const maxStopTime = config.getEnv('queue.bull.gracefulShutdownTimeout') * 1000;
|
||||
|
||||
|
@ -483,7 +483,7 @@ export class Worker extends BaseCommand {
|
|||
});
|
||||
|
||||
await new Promise<void>((resolve) => server.listen(port, () => resolve()));
|
||||
await this.externalHooks.run('worker.ready');
|
||||
await this.externalHooks?.run('worker.ready');
|
||||
this.logger.info(`\nn8n worker health check via, port ${port}`);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue