mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix(core): Decouple removing and closing destination from actually deleting it (#17614)
This commit is contained in:
committed by
GitHub
parent
a98ed2ca49
commit
b09f73701d
@@ -269,6 +269,7 @@ export class E2EController {
|
|||||||
private async resetLogStreaming() {
|
private async resetLogStreaming() {
|
||||||
for (const id in this.eventBus.destinations) {
|
for (const id in this.eventBus.destinations) {
|
||||||
await this.eventBus.removeDestination(id, false);
|
await this.eventBus.removeDestination(id, false);
|
||||||
|
await this.eventBus.deleteDestination(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ export class EventBusController {
|
|||||||
@GlobalScope('eventBusDestination:delete')
|
@GlobalScope('eventBusDestination:delete')
|
||||||
async deleteDestination(req: AuthenticatedRequest) {
|
async deleteDestination(req: AuthenticatedRequest) {
|
||||||
if (isWithIdString(req.query)) {
|
if (isWithIdString(req.query)) {
|
||||||
return await this.eventBus.removeDestination(req.query.id);
|
await this.eventBus.removeDestination(req.query.id);
|
||||||
|
return await this.eventBus.deleteDestination(req.query.id);
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestError('Query is missing id');
|
throw new BadRequestError('Query is missing id');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,20 +240,20 @@ export class MessageEventBus extends EventEmitter {
|
|||||||
return result.sort((a, b) => (a.__type ?? '').localeCompare(b.__type ?? ''));
|
return result.sort((a, b) => (a.__type ?? '').localeCompare(b.__type ?? ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeDestination(
|
async removeDestination(id: string, notifyWorkers: boolean = true) {
|
||||||
id: string,
|
|
||||||
notifyWorkers: boolean = true,
|
|
||||||
): Promise<DeleteResult | undefined> {
|
|
||||||
let result;
|
|
||||||
if (Object.keys(this.destinations).includes(id)) {
|
if (Object.keys(this.destinations).includes(id)) {
|
||||||
await this.destinations[id].close();
|
await this.destinations[id].close();
|
||||||
result = await this.destinations[id].deleteFromDb();
|
|
||||||
delete this.destinations[id];
|
delete this.destinations[id];
|
||||||
}
|
}
|
||||||
if (notifyWorkers) {
|
if (notifyWorkers) {
|
||||||
void this.publisher.publishCommand({ command: 'restart-event-bus' });
|
void this.publisher.publishCommand({ command: 'restart-event-bus' });
|
||||||
}
|
}
|
||||||
return result;
|
}
|
||||||
|
|
||||||
|
async deleteDestination(id: string): Promise<DeleteResult | undefined> {
|
||||||
|
return await this.eventDestinationsRepository.delete({
|
||||||
|
id,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async trySendingUnsent(msgs?: EventMessageTypes[]) {
|
private async trySendingUnsent(msgs?: EventMessageTypes[]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user