From 6cf03d987c28af7fdc7867d63f791720a0464a27 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 26 Feb 2026 08:47:29 -0800 Subject: [PATCH] cleanup --- .plans/16c-pr89-remediation-checklist.md | 13 ++----------- apps/server/src/config.ts | 7 +++++++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.plans/16c-pr89-remediation-checklist.md b/.plans/16c-pr89-remediation-checklist.md index 8531c5f860ba2f612f4311791c04fda670f857cb..74489a13fb19f3206ab6b59791136f8f1cd1aa57 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.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent: - - 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.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent: + - Status: `DONE` - Verdict: `partially-valid` - Severity: `Low` - Area: `Other` diff --git a/apps/server/src/config.ts b/apps/server/src/config.ts index 1dc0573a62c5cb96fc5e056dabd660dceeb79069..ad011173013c0701e7d898bc8f98c7473ac0654a 100644 --- a/apps/server/src/config.ts +++ b/apps/server/src/config.ts @@ -66,6 +66,7 @@ export class NetService extends ServiceMap.Service( static readonly layer = Layer.succeed(NetService, { findAvailablePort: (preferred) => Effect.callback((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( Effect.fail(new NetError({ message: "Failed to find an available port", cause })), ); }); + fallbackServer = fallback; + }); + + return Effect.sync(() => { + server.close(); + fallbackServer?.close(); }); }), }); -- 2.54.0