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
42};42};
43 43
44const closeServerHandlers = async (handlers: ServerHandlers): Promise<void> => {44const closeServerHandlers = async (handlers: ServerHandlers): Promise<void> => {
45 await Promise.all([45 await Effect.runPromise(
46 handlers.api.dispose().catch(() => undefined),46 Effect.all(
47 handlers.mcp.close().catch(() => undefined),47 [
48 ]);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 );
49};60};
50 61
51export const createServerHandlers = async (): Promise<ServerHandlers> => {62export const createServerHandlers = async (): Promise<ServerHandlers> => {
@@ -107,5 +118,10 @@ export const getServerHandlers = (): Promise<ServerHandlers> => · 55 unmodified lines
107 serverHandlersRuntime.runPromise(ServerHandlersService.asEffect());118 serverHandlersRuntime.runPromise(ServerHandlersService.asEffect());
108 119
109export const disposeServerHandlers = async (): Promise<void> => {120export 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 );
111};127};
apps/local/vite.config.ts+3−0
@@ -6,10 +6,12 @@ import tailwindcss from "@tailwindcss/vite"; · 5 unmodified lines
6import { tanstackRouter } from "@tanstack/router-plugin/vite";6import { tanstackRouter } from "@tanstack/router-plugin/vite";
7import executorVitePlugin from "@executor-js/vite-plugin";7import executorVitePlugin from "@executor-js/vite-plugin";
8 8
9// oxlint-disable-next-line executor/no-json-parse -- boundary: Vite config reads package metadata from package.json
9const rootPackage = JSON.parse(10const rootPackage = JSON.parse(
10 readFileSync(new URL("../../package.json", import.meta.url), "utf8"),11 readFileSync(new URL("../../package.json", import.meta.url), "utf8"),
11) as { version: string; homepage?: string; repository?: string | { url?: string } };12) as { version: string; homepage?: string; repository?: string | { url?: string } };
12 13
14// oxlint-disable-next-line executor/no-json-parse -- boundary: Vite config reads package metadata from package.json
13const cliPackage = JSON.parse(15const cliPackage = JSON.parse(
14 readFileSync(new URL("../cli/package.json", import.meta.url), "utf8"),16 readFileSync(new URL("../cli/package.json", import.meta.url), "utf8"),
15) as { version?: string };17) as { version?: string };
@@ -43,6 +45,7 @@ function executorApiPlugin(): Plugin { · 27 unmodified lines
43 45
44 if (!isApi && !isMcp) return next();46 if (!isApi && !isMcp) return next();
45 47
48 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: Vite middleware must convert handler failures into HTTP 500 responses
46 try {49 try {
47 if (!handlers) {50 if (!handlers) {
48 const { getServerHandlers } = await import("./src/server/main");51 const { getServerHandlers } = await import("./src/server/main");