Skip to content

Commit 8de8598

Browse files
committed
fixing dev server leak
1 parent a02a66c commit 8de8598

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/lib/server/SessionStore.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,16 @@ export class SessionStore {
190190
*/
191191
startCleanupInterval() {
192192
// Clean up every hour
193+
// Use unref() to prevent this interval from keeping the process alive during build
193194
this.cleanupInterval = setInterval(() => {
194195
this.cleanupExpiredSessions();
195196
}, 60 * 60 * 1000);
197+
198+
// Allow Node.js to exit even if this interval is still active
199+
// This is especially important during build processes
200+
if (this.cleanupInterval.unref) {
201+
this.cleanupInterval.unref();
202+
}
196203
}
197204

198205
/**

vite.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { sveltekit } from '@sveltejs/kit/vite';
22
import { defineConfig } from 'vite';
33

4-
import { Server } from 'socket.io';
5-
import { createPortalServer } from './src/lib/server/PortalServer.js';
6-
74
const webSocketServer = {
85
name: 'webSocketServer',
9-
configureServer(server) {
6+
async configureServer(server) {
107
if (!server.httpServer || process.env.NODE_ENV == 'production') return;
118

9+
// Dynamic import - only load when actually needed
10+
const { Server } = await import('socket.io');
11+
const { createPortalServer } = await import('./src/lib/server/PortalServer.js');
12+
1213
// Get allowed origins from environment variable or use localhost defaults
1314
const allowedOrigins = process.env.ALLOWED_ORIGINS
1415
? process.env.ALLOWED_ORIGINS.split(',').map(origin => origin.trim())

0 commit comments

Comments
 (0)