Tidying up static files

This commit is contained in:
Jerome 2025-07-10 11:17:11 +01:00
commit 46c71a9857
No known key found for this signature in database
6 changed files with 12 additions and 102 deletions

View file

@ -1,98 +0,0 @@
#!/bin/bash
# Script to debug why Jest tests hang after completion
echo "=== Starting Jest test hang debugging ==="
echo "Expected: Tests should exit within 5 seconds"
echo "Actual: Tests hang indefinitely"
echo ""
# Run tests with timeout and capture output
echo "Running tests with 10 second timeout..."
timeout 10s npm test > test_output.log 2>&1 &
TEST_PID=$!
# Monitor the test process
sleep 1
echo "Test process PID: $TEST_PID"
# Wait for either completion or timeout
wait $TEST_PID
EXIT_CODE=$?
echo ""
echo "=== Test Results ==="
if [ $EXIT_CODE -eq 124 ]; then
echo "❌ TESTS TIMED OUT (hung after 10 seconds)"
else
echo "✅ Tests completed normally with exit code: $EXIT_CODE"
fi
echo ""
echo "=== Test Output (last 20 lines) ==="
tail -20 test_output.log
echo ""
echo "=== Checking for Jest hanging indicators ==="
if grep -q "Jest did not exit one second after the test run has completed" test_output.log; then
echo "❌ Found Jest hanging message"
echo ""
echo "=== Common causes of Jest hanging ==="
echo "1. Unclosed database connections"
echo "2. Open timers/intervals"
echo "3. Open file handles"
echo "4. Unresolved promises"
echo "5. WebSocket connections"
echo "6. Event listeners not cleaned up"
echo ""
echo "=== Analyzing test files for potential issues ==="
# Check for Redis connections
echo "Checking for Redis connection issues..."
grep -r "redisClient" src/ --include="*.test.ts" | head -5
# Check for timers
echo ""
echo "Checking for setTimeout/setInterval..."
grep -r "setTimeout\|setInterval" src/ --include="*.test.ts" | head -5
# Check for event listeners
echo ""
echo "Checking for event listeners..."
grep -r "addEventListener\|on(" src/ --include="*.test.ts" | head -5
echo ""
echo "=== Suggested fixes ==="
echo "1. Add --detectOpenHandles to Jest config"
echo "2. Ensure all Redis connections are closed in afterAll/afterEach"
echo "3. Clear all timers in test cleanup"
echo "4. Add explicit process.exit() if needed"
else
echo "✅ No Jest hanging message found"
fi
echo ""
echo "=== Running with --detectOpenHandles ==="
echo "This will show what's keeping Node.js alive..."
timeout 15s npm test -- --detectOpenHandles > detect_handles.log 2>&1 &
DETECT_PID=$!
wait $DETECT_PID
DETECT_EXIT=$?
if [ $DETECT_EXIT -eq 124 ]; then
echo "❌ --detectOpenHandles also timed out"
else
echo "✅ --detectOpenHandles completed"
fi
echo ""
echo "=== Open handles output ==="
tail -30 detect_handles.log
echo ""
echo "=== Cleanup ==="
rm -f test_output.log detect_handles.log
echo "Debug complete!"

View file

@ -7,7 +7,8 @@
"scripts": {
"start": "node dist/index.js",
"dev": "tsx watch src/index.ts",
"build": "tsc",
"build": "tsc && npm run copy-static",
"copy-static": "mkdir -p dist/static && cp -r src/static/* dist/static/",
"lint": "eslint src/",
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},

View file

@ -72,7 +72,7 @@ export async function handleSSEConnection(req: Request, res: Response) {
logger.info('Listening on Redis channel', {
sessionId: transport.sessionId,
channel: redisChannel
channel: redisChannelForSession(transport.sessionId)
});
await mcpServer.connect(transport);
}

View file

@ -2,6 +2,8 @@ import { BearerAuthMiddlewareOptions, requireBearerAuth } from "@modelcontextpro
import { AuthRouterOptions, mcpAuthRouter } from "@modelcontextprotocol/sdk/server/auth/router.js";
import cors from "cors";
import express from "express";
import path from "path";
import { fileURLToPath } from "url";
import { EverythingAuthProvider } from "./auth/provider.js";
import { BASE_URI, PORT } from "./config.js";
import { authContext } from "./handlers/common.js";
@ -13,6 +15,10 @@ import { logger } from "./utils/logger.js";
const app = express();
// Get the directory of the current module
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Base security middleware - applied to all routes
const baseSecurityHeaders = (req: express.Request, res: express.Response, next: express.NextFunction) => {
// Basic security headers
@ -150,7 +156,8 @@ app.delete("/mcp", cors(corsOptions), bearerAuth, authContext, handleStreamableH
// Static assets
app.get("/mcp-logo.png", (req, res) => {
res.sendFile("mcp.png", { root: "." });
const logoPath = path.join(__dirname, "static", "mcp.png");
res.sendFile(logoPath);
});
// Upstream auth routes

BIN
src/static/mcp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -169,4 +169,4 @@ class StructuredLogger {
export const logger = new StructuredLogger();
// Re-export for convenience
export { LogContext, StructuredLogEntry };
export type { LogContext, StructuredLogEntry };