A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
test(server): drop wall-clock MCP health benchmark, fix cold-import timeout
Amruth Pillai660603c3c756
diff --git a/apps/server/src/http/app.test.ts b/apps/server/src/http/app.test.tsindex e85e05037..fcdd7ef2c 100644--- a/apps/server/src/http/app.test.ts+++ b/apps/server/src/http/app.test.ts@@ -111,6 +111,7 @@ beforeEach(() => {});describe("createApp", () => {+ // The first case pays for the cold import of the whole app, which takes seconds under a parallel run.it.each([["127.0.0.1", "127.0.0.1", "198.51.100.1", "198.51.100.1"],["127.0.0.1", "::ffff:127.0.0.1", "198.51.100.1", "198.51.100.1"],@@ -119,15 +120,19 @@ describe("createApp", () => {["127.0.0.1", "127.0.0.1", "192.0.2.99, 198.51.100.1", "198.51.100.1"],["127.0.0.1", "203.0.113.9", "198.51.100.1", "203.0.113.9"],["127.0.0.1", "127.0.0.1", "invalid, 198.51.100.1", "127.0.0.1"],- ])("resolves auth client through trusted %s from socket %s", async (proxy, peer, forwarded, expected) => {- mocks.trustedProxies.push(proxy);- const { createApp } = await import("./app");- const request = new Request("http://localhost/api/auth/sign-in/email", {- headers: { "x-forwarded-for": forwarded },- });- await createApp().fetch(request, transportEnv(peer));- expect(mocks.handleAuth).toHaveBeenCalledWith(request, expected);- });+ ])(+ "resolves auth client through trusted %s from socket %s",+ async (proxy, peer, forwarded, expected) => {+ mocks.trustedProxies.push(proxy);+ const { createApp } = await import("./app");+ const request = new Request("http://localhost/api/auth/sign-in/email", {+ headers: { "x-forwarded-for": forwarded },+ });+ await createApp().fetch(request, transportEnv(peer));+ expect(mocks.handleAuth).toHaveBeenCalledWith(request, expected);+ },+ 15_000,+ );it("routes /api/auth/oauth to the OAuth bridge before the Better Auth wildcard", async () => {const { createApp } = await import("./app");@@ -139,8 +144,7 @@ describe("createApp", () => {await expect(response.text()).resolves.toBe("oauth");expect(mocks.handleOAuth).toHaveBeenCalledWith(request);expect(mocks.handleAuth).not.toHaveBeenCalled();- // The first test pays for the cold import of the whole app, which takes seconds under a parallel run.- }, 15_000);+ });it("uses the transport address for public PDF fallback despite rotated forwarding headers", async () => {const { createApp } = await import("./app");diff --git a/apps/server/src/mcp/discovery.test.ts b/apps/server/src/mcp/discovery.test.tsindex 926d02824..7d756891e 100644--- a/apps/server/src/mcp/discovery.test.ts+++ b/apps/server/src/mcp/discovery.test.ts@@ -1,9 +1,7 @@import type { RequestAuthentication } from "@reactive-resume/api/context";-import { once } from "node:events";import { Socket } from "node:net";import { setImmediate } from "node:timers/promises";import { afterEach, beforeEach, expect, it, vi } from "vitest";-import { serve } from "@hono/node-server";import { Pool } from "pg";import z from "zod";@@ -160,45 +158,6 @@ it("reuses static schema conversions across separate authenticated discovery reqexpect(conversions.mock.calls.length).toBe(0);}, 30_000);-it("keeps concurrent HTTP health checks responsive during repeated MCP discovery", async () => {- const { createApp } = await import("../http/app");- const app = createApp({ serveStatic: false, trustedClient: () => "127.0.0.1" });- const server = serve({ fetch: app.fetch, port: 0 });- try {- if (!server.listening) await once(server, "listening");- const address = server.address();- if (!address || typeof address === "string") throw new Error("Missing HTTP address");- const url = `http://127.0.0.1:${address.port}`;- const input = request();- const body = await input.text();- const started = performance.now();- const discovery = Promise.all(- Array.from({ length: 20 }, async () => {- const response = await fetch(`${url}/mcp`, { method: "POST", headers: input.headers, body });- expect(response.status).toBe(200);- expect((await response.json()).result.tools.length).toBeGreaterThan(70);- }),- );- const health = Promise.all(- Array.from({ length: 3 }, async () => {- await setImmediate();- const response = await fetch(`${url}/api/health`);- expect(response.status).toBe(200);- expect((await response.json()).status).toBe("healthy");- return performance.now() - started;- }),- );- const [, healthDurations] = await Promise.all([discovery, health]);- console.info("20 concurrent MCP discoveries milliseconds", Math.round(performance.now() - started));- console.info("Concurrent HTTP health milliseconds", healthDurations.map(Math.round));- expect(Math.max(...healthDurations)).toBeLessThan(1_000);- expect(mocks.execute).toHaveBeenCalledTimes(3);- expect(mocks.healthcheck).toHaveBeenCalledTimes(3);- } finally {- await new Promise<void>((resolve) => server.close(() => resolve()));- }-}, 30_000);-it("keeps credentials, permissions, headers and callbacks isolated between requests", async () => {const { handleMcp } = await import("./handler");for (const token of ["reader", "writer", "reader"]) {