From 9fae5f22b250600d2b3909b833b4c15de9543b69 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Fri, 5 Dec 2025 00:27:16 +1000 Subject: [PATCH] fix: make Prisma import lazy in playground to prevent module initialization failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove top-level Prisma import from dynamic-tool-loader.ts - Use dynamic import in reportToolFailure function instead - Prevents entire module from failing if DATABASE_URL is missing - Fixes API route timeout issue caused by module initialization failure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/playground/src/lib/dynamic-tool-loader.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/playground/src/lib/dynamic-tool-loader.ts b/apps/playground/src/lib/dynamic-tool-loader.ts index 9133d55..f2be8ae 100644 --- a/apps/playground/src/lib/dynamic-tool-loader.ts +++ b/apps/playground/src/lib/dynamic-tool-loader.ts @@ -1,4 +1,3 @@ -import { prisma } from '@tpmjs/db'; import { jsonSchema, tool } from 'ai'; // Cache for tool wrappers (process-level) @@ -49,6 +48,9 @@ async function reportToolFailure( phase: 'import' | 'execution' ): Promise { try { + // Lazy load Prisma to avoid module initialization failures + const { prisma } = await import('@tpmjs/db'); + // Find the tool in the database const tool = await prisma.tool.findFirst({ where: {