Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

cleanup

Julius Marminge6cf03d987c28
diff --git a/.plans/16c-pr89-remediation-checklist.md b/.plans/16c-pr89-remediation-checklist.md
index 8531c5f86..74489a13f 100644
--- a/.plans/16c-pr89-remediation-checklist.md
+++ b/.plans/16c-pr89-remediation-checklist.md
@@ -333,15 +333,6 @@ Counts: active `51` (`valid=33`, `partially-valid=18`), closed-invalid `6`
### Phase 6
-- [ ] `C024` In `executeUnprepared`, preparing outside an effect and not closing the statement can cause uncaught errors and leaks. Suggest wrapping with `Effect.acquireUseRelease`: prepare in acquire (error-safe) and `finalize` in release.
- - Status: `TODO`
- - Verdict: `partially-valid`
- - Severity: `Medium`
- - Area: `Other`
- - File: `apps/server/src/persistence/NodeSqliteClient.ts:145`
- - Threads: PRRT_kwDORLtfbc5whxX9
- - Audit note: prepare() still outside managed effect boundary; failure handling risk remains.
-
- [ ] `C028` Branch sync dispatches both server and stale local update
- Status: `TODO`
- Verdict: `partially-valid`
@@ -351,8 +342,8 @@ Counts: active `51` (`valid=33`, `partially-valid=18`), closed-invalid `6`
- Threads: PRRT_kwDORLtfbc5v-XCu
- Audit note: Optimistic local+server dual update is intentional but can temporarily diverge.
-- [ ] `C037` `Effect.callback` should return a cleanup function to close the server(s) on fiber interruption. Without it, the `Net.Server` handles keep the process alive and leak the port if the effect is cancelled. <details> <summary>🚀 Reply "<strong>fix it for me</strong>" or copy this <strong>AI Prompt</strong> for your agent:</summary>
- - Status: `TODO`
+- [x] `C037` `Effect.callback` should return a cleanup function to close the server(s) on fiber interruption. Without it, the `Net.Server` handles keep the process alive and leak the port if the effect is cancelled. <details> <summary>🚀 Reply "<strong>fix it for me</strong>" or copy this <strong>AI Prompt</strong> for your agent:</summary>
+ - Status: `DONE`
- Verdict: `partially-valid`
- Severity: `Low`
- Area: `Other`
diff --git a/apps/server/src/config.ts b/apps/server/src/config.ts
index 1dc0573a6..ad0111730 100644
--- a/apps/server/src/config.ts
+++ b/apps/server/src/config.ts
@@ -66,6 +66,7 @@ export class NetService extends ServiceMap.Service<NetService, NetServiceShape>(
static readonly layer = Layer.succeed(NetService, {
findAvailablePort: (preferred) =>
Effect.callback<number, NetError>((resume) => {
+ let fallbackServer: Net.Server | null = null;
const server = Net.createServer();
server.listen(preferred, () => {
server.close(() => resume(Effect.succeed(preferred)));
@@ -88,6 +89,12 @@ export class NetService extends ServiceMap.Service<NetService, NetServiceShape>(
Effect.fail(new NetError({ message: "Failed to find an available port", cause })),
);
});
+ fallbackServer = fallback;
+ });
+
+ return Effect.sync(() => {
+ server.close();
+ fallbackServer?.close();
});
}),
});