Fix: Use sync fs operations instead of fs/promises

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 <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2025-12-16 14:56:38 -08:00
co-authored by Claude Opus 4.5
parent f7b42be23b
commit 13f4714b5d
2 changed files with 10 additions and 7 deletions
+6 -4
View File
@@ -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) {
+4 -3
View File
@@ -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) {