refactor(core): Provide clearer errors on task runner rejection (#14666)

This commit is contained in:
Iván Ovejero
2025-04-16 10:28:47 +02:00
committed by GitHub
parent bc269234cf
commit 8b99f42009

View File

@@ -258,17 +258,20 @@ export abstract class TaskRunner extends EventEmitter {
request.resolve(nodeTypes);
}
hasOpenTasks() {
/**
* Whether the task runner has capacity to accept more tasks.
*/
hasOpenTaskSlots() {
return this.runningTasks.size < this.maxConcurrency;
}
offerAccepted(offerId: string, taskId: string) {
if (!this.hasOpenTasks()) {
if (!this.hasOpenTaskSlots()) {
this.openOffers.delete(offerId);
this.send({
type: 'runner:taskrejected',
taskId,
reason: 'No open task slots',
reason: 'No open task slots - runner already at capacity',
});
return;
}
@@ -278,7 +281,7 @@ export abstract class TaskRunner extends EventEmitter {
this.send({
type: 'runner:taskrejected',
taskId,
reason: 'Offer expired and no open task slots',
reason: 'Offer expired - not accepted within validity window',
});
return;
} else {