fix: make Prisma import lazy in playground to prevent module initialization failures

- 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 <noreply@anthropic.com>
This commit is contained in:
Ajax Davis 2025-12-05 00:27:16 +10:00
parent 3cfc141944
commit 9fae5f22b2

View file

@ -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<void> {
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: {