Skip to main content
The Great Prisma Cache Mystery

The Great Prisma Cache Mystery

Andrius LukminasAndrius LukminasJanuary 15, 20263 min read178 views

The Symptom

After adding a new log_settings model to our Prisma schema and running db:generate, the API endpoint crashed:

Cannot read properties of undefined (reading 'upsert')

The model was clearly in the schema. Prisma Studio showed the table. But prisma.log_settings was undefined at runtime.

The Investigation

We checked everything:

  • Schema syntax - correct
  • Migration status - applied
  • Generated client - includes the model
  • TypeScript types - present

The Culprit: Node.js Module Cache

The dev server was running continuously. When we regenerated the Prisma client, the new code was written to disk, but Node.js had already loaded and cached the old PrismaClient instance.

The Fix

# Regenerate client (may already be done)
npm run db:generate

# The crucial step: restart the dev server
sudo systemctl restart boottify-control

Prevention

We now always restart the dev server after schema changes. It's in our CLAUDE.md documentation as a standard procedure.

Related Articles

Comments

0/5000 characters

Comments from guests require moderation.