Skip to content

Commit c04e1df

Browse files
comfy-pr-botsnomiaoclaude
authored
fix: register worker task name at startup to prevent spurious early exit (#165)
The watchWorkerInstancesLoop captures `me` with task=undefined at startup because the initial getWorkerInstance() call has no task parameter. Any other process that also calls getWorkerInstance() without a task (e.g. updateGithubActionTask scheduler running at the same time) matches the task===undefined condition and incorrectly evicts the main bot process. Fix: call getWorkerInstance("ComfyPR Bot Running") before Promise.all so that me.task is already set when watchWorkerInstancesLoop starts. Only a competing instance with the same task name can now trigger an exit. Co-authored-by: snomiao <snomiao@gmail.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 3101578 commit c04e1df

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ import { updateAuthors } from "./updateAuthors";
77
import { updateCNRepos } from "./updateCNRepos";
88
import { runFollowRuleSet } from "./updateFollowRuleSet";
99
import { updateSlackMessages } from "./updateSlackMessages";
10+
import { getWorkerInstance } from "./WorkerInstances";
1011
import { tLog } from "./utils/tLog";
1112

1213
const logger = createLogger("main");
1314

1415
if (import.meta.main) {
16+
// Register task name immediately so watchWorkerInstancesLoop captures me.task correctly.
17+
// Without this, me.task is undefined and any other process calling getWorkerInstance()
18+
// without a task name would incorrectly evict this process.
19+
await getWorkerInstance("ComfyPR Bot Running");
1520
await Promise.all([
1621
// try send msgs that didn't send in last run
1722
updateSlackMessages(),

0 commit comments

Comments
 (0)