How to Fix Nodemon Not Restarting (Stuck on Old Code) with Turso / libSQL
If you're building a Node.js / Express app using Turso (@libsql/client) and notice that nodemon isn't updating your newly added routes, you might have run into a very common development trap! You m...

Source: DEV Community
If you're building a Node.js / Express app using Turso (@libsql/client) and notice that nodemon isn't updating your newly added routes, you might have run into a very common development trap! You might see things like: Cannot GET /new-route even though you just wrote the code for it. EADDRINUSE: address already in use :::3000 hiding in your terminal logs. 🐛 What is happening? To make queries fast, the @libsql/client holds a persistent, open socket connection to your Turso database. Because Node.js is designed to never exit as long as there is an active background process (like a database connection), whenever nodemon tries to restart your app, the old process refuses to die. The old process becomes a "zombie" that keeps running on Port 3000, preventing your updated code from taking over the port. 🛠️ The Solution: Graceful Shutdown To fix this, you don't need a new package. You just need to tell your Node.js app to close the database connection whenever nodemon sends the restart signa