mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -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,
|
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();
|
||||||
|
|
Loading…
Reference in a new issue