fix: serialize local-agent heartbeats

This commit is contained in:
kris
2026-03-31 21:49:46 +08:00
parent 02fcc56332
commit be31503d22
3 changed files with 59 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import os from "node:os";
import { join, resolve } from "node:path";
import { discoverCodexProjectCandidatesInWorker } from "./codex-session-discovery.mjs";
import { buildCodexTaskExecution } from "./codex-task-runner.mjs";
import { createSerializedRunner } from "./serialized-runner.mjs";
async function loadConfig(configPath) {
const raw = await readFile(resolve(configPath), "utf8");
@@ -493,7 +494,7 @@ const runtime = {
lastProjectDiscoverySummary: null,
};
async function heartbeat() {
async function performHeartbeat() {
try {
const heartbeatProjects = await resolveHeartbeatProjects(config, runtime);
const result = await postHeartbeat(config, runtime, heartbeatProjects);
@@ -567,6 +568,8 @@ async function heartbeat() {
}
}
const heartbeat = createSerializedRunner(performHeartbeat);
const server = createServer(async (request, response) => {
if (request.url === "/health") {
response.writeHead(200, { "Content-Type": "application/json" });