mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(Email Trigger (IMAP) Node): Ensure connection close does not block deactivation (#10689)
This commit is contained in:
@@ -14,7 +14,7 @@ import type {
|
|||||||
ITriggerResponse,
|
ITriggerResponse,
|
||||||
JsonObject,
|
JsonObject,
|
||||||
} from 'n8n-workflow';
|
} 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 type { ImapSimple, ImapSimpleOptions, Message, MessagePart } from '@n8n/imap';
|
||||||
import { connect as imapConnect, getParts } 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
|
// When workflow and so node gets set to inactive close the connection
|
||||||
async function closeFunction() {
|
const closeFunction = async () => {
|
||||||
closeFunctionWasCalled = true;
|
closeFunctionWasCalled = true;
|
||||||
if (reconnectionInterval) {
|
if (reconnectionInterval) {
|
||||||
clearInterval(reconnectionInterval);
|
clearInterval(reconnectionInterval);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
if (connection.closeBox) await connection.closeBox(false);
|
if (connection.closeBox) await connection.closeBox(false);
|
||||||
connection.end();
|
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
|
// Resolve returned-promise so that waiting errors can be emitted
|
||||||
returnedPromise.resolve();
|
returnedPromise.resolve();
|
||||||
|
|||||||
Reference in New Issue
Block a user