From 430d8261abae4d20c55851e6d0c6bd8a8799ae56 Mon Sep 17 00:00:00 2001 From: Aleh Yablonski Date: Thu, 5 Feb 2026 15:48:22 +0300 Subject: [PATCH] feat(rebuild-instance): remove unused code for rebuild instances --- src/server/utils/queue/index.ts | 5 +---- src/server/utils/queue/queue.ts | 30 +----------------------------- src/server/utils/queue/utils.ts | 21 --------------------- 3 files changed, 2 insertions(+), 54 deletions(-) diff --git a/src/server/utils/queue/index.ts b/src/server/utils/queue/index.ts index 04d7113..a3a3b86 100644 --- a/src/server/utils/queue/index.ts +++ b/src/server/utils/queue/index.ts @@ -13,10 +13,7 @@ const runQueue = async () => { // 1. Delete instances queue.deleteInstances(), - // 2. Restart failed builds (re-add them to build queue) - queue.restartFailedBuilds(), - - // 3. Build instances + // 2. Build instances queue.buildInstances(), ]).catch((e) => { getNodeKit().ctx.logError('QUEUE::runQueue', wrapInternalError(e)); diff --git a/src/server/utils/queue/queue.ts b/src/server/utils/queue/queue.ts index e112fae..08dba56 100644 --- a/src/server/utils/queue/queue.ts +++ b/src/server/utils/queue/queue.ts @@ -3,24 +3,17 @@ import * as db from '../../utils/db'; import {wrapInternalError} from '../common'; import {BUILDS_LIMIT} from './constants'; -import { - deleteInstance, - generateInstance, - getInstancesToRestart, - restartFailedBuilds, -} from './utils'; +import {deleteInstance, generateInstance} from './utils'; export class Queue { declare private locker: { deleteInstances: boolean; - restartFailedBuilds: boolean; buildInstances: boolean; }; constructor() { this.locker = { deleteInstances: false, - restartFailedBuilds: false, buildInstances: false, }; } @@ -46,27 +39,6 @@ export class Queue { } }; - restartFailedBuilds = async () => { - if (this.locker.restartFailedBuilds) { - return; - } - - try { - this.locker.restartFailedBuilds = true; - const instancesToRestart = await getInstancesToRestart(); - - if (instancesToRestart.length > 0) { - restartFailedBuilds(instancesToRestart).catch((e) => { - getNodeKit().ctx.logError('QUEUE::restartFailedBuilds', wrapInternalError(e)); - }); - } - } catch (e) { - getNodeKit().ctx.logError('QUEUE::restartFailedBuilds', wrapInternalError(e)); - } finally { - this.locker.restartFailedBuilds = false; - } - }; - buildInstances = async () => { if (this.locker.buildInstances) { return; diff --git a/src/server/utils/queue/utils.ts b/src/server/utils/queue/utils.ts index 85751ca..d0d3279 100644 --- a/src/server/utils/queue/utils.ts +++ b/src/server/utils/queue/utils.ts @@ -8,7 +8,6 @@ import type {GenerateInstanceData, InstanceObservableEmitValue} from '../../mode import * as db from '../../utils/db'; import {formatError} from '../common'; import {fetchProjectConfig} from '../farmJsonConfig'; -import {addInstanceToGenerateQueue} from '../instance'; import type {Stats} from '../stats'; import {sendStats} from '../stats'; @@ -176,23 +175,3 @@ export const deleteInstance = async (instance: Instance) => { await getFarmProvider().deleteInstance(instance.hash); await db.clearInstanceData(instance.hash); }; - -export const getInstancesToRestart = async () => { - const generatingInstances = await db.getInstancesByStatus({status: 'generating'}); - const instances = await getFarmProvider().getInstances(); - - const instancesToRestart: Instance[] = []; - generatingInstances.forEach((instance) => { - const item = instances.find((p) => p.hash === instance.hash); - // Provider creates new process right before starting the app, so we need to restart only errored instances here. - if (item?.status === 'errored') { - instancesToRestart.push(instance); - } - }); - - return instancesToRestart; -}; - -export const restartFailedBuilds = async (instances: Instance[]) => { - await Promise.all(instances.map((instance) => addInstanceToGenerateQueue(instance))); -};