mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(Email Trigger (IMAP) Node): Ensure connection close does not block deactivation (#10689)
This commit is contained in:
parent
ff7354228c
commit
156eb72ebe
|
@ -14,7 +14,7 @@ import type {
|
|||
ITriggerResponse,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeOperationError, TriggerCloseError } from 'n8n-workflow';
|
||||
|
||||
import type { ImapSimple, ImapSimpleOptions, Message, MessagePart } from '@n8n/imap';
|
||||
import { connect as imapConnect, getParts } from '@n8n/imap';
|
||||
|
@ -669,14 +669,19 @@ export class EmailReadImapV2 implements INodeType {
|
|||
}
|
||||
|
||||
// When workflow and so node gets set to inactive close the connection
|
||||
async function closeFunction() {
|
||||
const closeFunction = async () => {
|
||||
closeFunctionWasCalled = true;
|
||||
if (reconnectionInterval) {
|
||||
clearInterval(reconnectionInterval);
|
||||
}
|
||||
try {
|
||||
if (connection.closeBox) await connection.closeBox(false);
|
||||
connection.end();
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line n8n-nodes-base/node-execute-block-wrong-error-thrown
|
||||
throw new TriggerCloseError(this.getNode(), { cause: error as Error, level: 'warning' });
|
||||
}
|
||||
};
|
||||
|
||||
// Resolve returned-promise so that waiting errors can be emitted
|
||||
returnedPromise.resolve();
|
||||
|
|
Loading…
Reference in a new issue