fix: cleanup dev server exit code

This commit is contained in:
lucas-neynar 2025-03-13 12:58:48 -07:00
parent 109569924d
commit f02b4064db
No known key found for this signature in database

20
dev.js
View File

@ -3,6 +3,7 @@ import { spawn } from 'child_process';
let tunnel; let tunnel;
let nextDev; let nextDev;
let isCleaningUp = false;
async function startDev() { async function startDev() {
// Start localtunnel and get URL // Start localtunnel and get URL
@ -16,16 +17,25 @@ async function startDev() {
}); });
// Handle cleanup // Handle cleanup
const cleanup = () => { const cleanup = async () => {
if (tunnel) { if (isCleaningUp) return;
tunnel.close(); isCleaningUp = true;
console.log('\n🌐 Tunnel closed');
} try {
if (nextDev) { if (nextDev) {
nextDev.kill(); nextDev.kill();
console.log('\n🛑 Next.js dev server stopped'); console.log('\n🛑 Next.js dev server stopped');
} }
if (tunnel) {
await tunnel.close();
console.log('\n🌐 Tunnel closed');
}
} catch (error) {
console.error('Error during cleanup:', error);
} finally {
process.exit(0); process.exit(0);
}
}; };
// Handle process termination // Handle process termination