fix: address review feedback for per-group queue reliability

- Fix startup recovery running before WhatsApp connects, which could
  permanently lose agent responses by advancing lastAgentTimestamp
  before sock is initialized
- Add 5s retry on container failure so messages aren't silently dropped
  until a new message arrives for the group
- Use `container stop` in shutdown instead of raw SIGTERM to CLI wrapper,
  ensuring proper container cleanup
- Replace unnecessary dynamic imports with static imports in processTaskIpc
- Guard JSON.parse of DB-stored last_agent_timestamp against corruption
- Validate MAX_CONCURRENT_CONTAINERS (default 5, min 1, NaN-safe)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-02-06 16:45:00 +02:00
parent eac9a6acfd
commit 03df69e9b5
5 changed files with 64 additions and 43 deletions

View File

@@ -184,7 +184,7 @@ function buildContainerArgs(mounts: VolumeMount[], containerName: string): strin
export async function runContainerAgent(
group: RegisteredGroup,
input: ContainerInput,
onProcess: (proc: ChildProcess) => void,
onProcess: (proc: ChildProcess, containerName: string) => void,
): Promise<ContainerOutput> {
const startTime = Date.now();
@@ -227,7 +227,7 @@ export async function runContainerAgent(
stdio: ['pipe', 'pipe', 'pipe'],
});
onProcess(container);
onProcess(container, containerName);
let stdout = '';
let stderr = '';