History

Clean local server tooling boundaries

Rhys Sullivan committed 6 months ago

Commit 46d1c241 parent b039b6e2 files · +24 −5Browse files

Unified · Split

2 files
  1. apps/local/src/server/main.ts +21 −5
  2. apps/local/vite.config.ts +3 −0
apps/local/src/server/main.ts+21−5
@@ -42,10 +42,21 @@ export type ServerHandlers = { · 41 unmodified lines
4242 };
4343
4444 const closeServerHandlers = async (handlers: ServerHandlers): Promise<void> => {
45− await Promise.all([
46− handlers.api.dispose().catch(() => undefined),
47− handlers.mcp.close().catch(() => undefined),
48− ]);
45+ await Effect.runPromise(
46+ Effect.all(
47+ [
48+ Effect.tryPromise({
49+ try: () => handlers.api.dispose(),
50+ catch: (cause) => cause,
51+ }).pipe(Effect.ignore),
52+ Effect.tryPromise({
53+ try: () => handlers.mcp.close(),
54+ catch: (cause) => cause,
55+ }).pipe(Effect.ignore),
56+ ],
57+ { concurrency: "unbounded" },
58+ ),
59+ );
4960 };
5061
5162 export const createServerHandlers = async (): Promise<ServerHandlers> => {
@@ -107,5 +118,10 @@ export const getServerHandlers = (): Promise<ServerHandlers> => · 55 unmodified lines
107118 serverHandlersRuntime.runPromise(ServerHandlersService.asEffect());
108119
109120 export const disposeServerHandlers = async (): Promise<void> => {
110− await serverHandlersRuntime.dispose().catch(() => undefined);
121+ await Effect.runPromise(
122+ Effect.tryPromise({
123+ try: () => serverHandlersRuntime.dispose(),
124+ catch: (cause) => cause,
125+ }).pipe(Effect.ignore),
126+ );
111127 };
apps/local/vite.config.ts+3−0
@@ -6,10 +6,12 @@ import tailwindcss from "@tailwindcss/vite"; · 5 unmodified lines
66 import { tanstackRouter } from "@tanstack/router-plugin/vite";
77 import executorVitePlugin from "@executor-js/vite-plugin";
88
9+// oxlint-disable-next-line executor/no-json-parse -- boundary: Vite config reads package metadata from package.json
910 const rootPackage = JSON.parse(
1011 readFileSync(new URL("../../package.json", import.meta.url), "utf8"),
1112 ) as { version: string; homepage?: string; repository?: string | { url?: string } };
1213
14+// oxlint-disable-next-line executor/no-json-parse -- boundary: Vite config reads package metadata from package.json
1315 const cliPackage = JSON.parse(
1416 readFileSync(new URL("../cli/package.json", import.meta.url), "utf8"),
1517 ) as { version?: string };
@@ -43,6 +45,7 @@ function executorApiPlugin(): Plugin { · 27 unmodified lines
4345
4446 if (!isApi && !isMcp) return next();
4547
48+ // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: Vite middleware must convert handler failures into HTTP 500 responses
4649 try {
4750 if (!handlers) {
4851 const { getServerHandlers } = await import("./src/server/main");