fix: wrap external hooks calls in a try catch (#4208)

This commit is contained in:
Omar Ajoue 2022-09-27 11:43:56 +02:00 committed by GitHub
parent 80e2d65933
commit ef378f2cf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@
/* eslint-disable import/no-dynamic-require */
/* eslint-disable no-restricted-syntax */
// eslint-disable-next-line import/no-cycle
import { LoggerProxy } from 'n8n-workflow';
import { Db, IExternalHooksClass, IExternalHooksFileData, IExternalHooksFunctions } from '.';
import config from '../config';
@ -87,8 +88,13 @@ class ExternalHooksClass implements IExternalHooksClass {
}
for (const externalHookFunction of this.externalHooks[hookName]) {
// eslint-disable-next-line no-await-in-loop
await externalHookFunction.apply(externalHookFunctions, hookParameters);
try {
// eslint-disable-next-line no-await-in-loop
await externalHookFunction.apply(externalHookFunctions, hookParameters);
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
LoggerProxy.info(`Error in external hook "${hookName}": ${error.message}`);
}
}
}