From 2d55d40405c4b810feadec77fc5e8e310f8397b5 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Sun, 14 Jun 2026 11:27:07 +0200 Subject: [PATCH] Fix dev server hang (broken dev script + IPv6 proxy stall) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `pnpm dev` never started the backend: the server dev script ran `node --experimental-strip-types src/index.ts`, but type-stripping doesn't rewrite the `.js` import specifiers to `.ts`, so it crashed on ERR_MODULE_NOT_FOUND. With no backend on :3000, the Vite proxy waited the full timeout on every /api call — the "Loading…" and "Signing in…" hangs. - server dev script -> `tsx watch` (resolves .js->.ts, has built-in watch). - Vite proxy targets 127.0.0.1 (not "localhost") so it never tries IPv6 ::1 first and stall — the backend binds IPv4. Belt-and-suspenders for the same hang, notably under WSL2 mirrored networking. Verified: pnpm dev boots the backend; health/auth/me ~5ms; browser login is instant (was minutes). --- apps/server/package.json | 3 ++- apps/web/vite.config.ts | 7 +++++-- pnpm-lock.yaml | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/server/package.json b/apps/server/package.json index 171dee5..ab53ee3 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "build": "tsc -b", - "dev": "node --env-file-if-exists=.env --watch --experimental-strip-types src/index.ts", + "dev": "tsx watch --env-file-if-exists=.env src/index.ts", "start": "node --env-file-if-exists=.env dist/index.js", "seed-admin": "node --env-file-if-exists=.env scripts/seed-admin.mjs", "typecheck": "tsc --noEmit", @@ -27,6 +27,7 @@ "devDependencies": { "@types/bcrypt": "6.0.0", "@types/node": "25.9.3", + "tsx": "4.22.4", "typescript": "6.0.3" } } diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index 1c3118c..7333b9c 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -9,8 +9,11 @@ export default defineConfig({ server: { port: 5173, proxy: { - "/api": "http://localhost:3000", - "/health": "http://localhost:3000", + // Use 127.0.0.1 (not "localhost") so the proxy never tries IPv6 ::1 + // first and stall — the backend binds IPv4. Avoids slow/hung requests, + // notably under WSL2 mirrored networking. + "/api": "http://127.0.0.1:3000", + "/health": "http://127.0.0.1:3000", }, }, build: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f77c999..edbe384 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,6 +60,9 @@ importers: '@types/node': specifier: 25.9.3 version: 25.9.3 + tsx: + specifier: 4.22.4 + version: 4.22.4 typescript: specifier: 6.0.3 version: 6.0.3