Skip to content

Commit 736aeba

Browse files
committed
refactor(server): trace the scope cleanup wait
1 parent d2aa1f9 commit 736aeba

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

‎apps/server/src/process/agentScope.ts‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ export const make = Effect.gen(function* () {
306306
(state.populated === undefined &&
307307
(state.activeState === "inactive" || state.activeState === "failed"));
308308

309-
const awaitStopped = (systemctl: string, unit: string) =>
310-
Effect.gen(function* () {
309+
const awaitStopped = Effect.fn("AgentScope.awaitStopped")(
310+
function* (systemctl: string, unit: string) {
311311
while (true) {
312312
const state = yield* readScope(systemctl, unit);
313313
if (state === undefined) {
@@ -319,17 +319,20 @@ export const make = Effect.gen(function* () {
319319
if (hasStopped(state)) return;
320320
yield* Effect.sleep(STOPPING_POLL_INTERVAL);
321321
}
322-
}).pipe(
323-
Effect.interruptible,
324-
Effect.timeoutOption("15 seconds"),
325-
Effect.flatMap((completed) =>
326-
completed._tag === "Some"
327-
? Effect.void
328-
: Effect.fail(
329-
new AgentScopeStopError({ unit, detail: "Agent scope did not finish stopping" }),
330-
),
322+
},
323+
(effect, _systemctl, unit) =>
324+
effect.pipe(
325+
Effect.interruptible,
326+
Effect.timeoutOption("15 seconds"),
327+
Effect.flatMap((completed) =>
328+
completed._tag === "Some"
329+
? Effect.void
330+
: Effect.fail(
331+
new AgentScopeStopError({ unit, detail: "Agent scope did not finish stopping" }),
332+
),
333+
),
331334
),
332-
);
335+
);
333336

334337
const stop = Effect.fn("AgentScope.stop")(function* (unit: string) {
335338
if (!unit.startsWith("t3code-") || !unit.endsWith(".scope")) {

0 commit comments

Comments
 (0)