From 13f4714b5dec1c176d7e3f45d34dbf072a651ee3 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Tue, 16 Dec 2025 14:56:38 -0800 Subject: [PATCH] Fix: Use sync fs operations instead of fs/promises MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fs/promises appears to hang on Vercel serverless functions. Switched to readdirSync/readFileSync which should work reliably. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- api/commands.js | 10 ++++++---- api/patterns.js | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api/commands.js b/api/commands.js index 86a66b087..db9c85759 100644 --- a/api/commands.js +++ b/api/commands.js @@ -1,4 +1,4 @@ -import { readdir, readFile } from "fs/promises"; +import { readdirSync, readFileSync } from "fs"; import { join, dirname } from "path"; import { fileURLToPath } from "url"; @@ -6,7 +6,7 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const PROJECT_ROOT = join(__dirname, ".."); -export default async function handler(request) { +export default function handler(request) { try { const sourceDir = join(PROJECT_ROOT, "source"); const commandsDir = join(sourceDir, "commands"); @@ -14,12 +14,14 @@ export default async function handler(request) { console.log("PROJECT_ROOT:", PROJECT_ROOT); console.log("commandsDir:", commandsDir); - const files = await readdir(commandsDir); + const files = readdirSync(commandsDir); + console.log("Files found:", files.length); + const commands = []; for (const file of files) { if (file.endsWith(".md")) { - const content = await readFile(join(commandsDir, file), "utf-8"); + const content = readFileSync(join(commandsDir, file), "utf-8"); const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/); if (frontmatterMatch) { diff --git a/api/patterns.js b/api/patterns.js index 7fec7e4d6..d797d8bbd 100644 --- a/api/patterns.js +++ b/api/patterns.js @@ -1,4 +1,4 @@ -import { readFile } from "fs/promises"; +import { readFileSync } from "fs"; import { join, dirname } from "path"; import { fileURLToPath } from "url"; @@ -6,14 +6,15 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const PROJECT_ROOT = join(__dirname, ".."); -export default async function handler(request) { +export default function handler(request) { try { const sourceDir = join(PROJECT_ROOT, "source"); const filePath = join(sourceDir, "patterns.md"); console.log("Reading patterns from:", filePath); - const content = await readFile(filePath, "utf-8"); + const content = readFileSync(filePath, "utf-8"); + console.log("File read, length:", content.length); const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/); if (!frontmatterMatch) {