Skip to content

Commit 9edcc8f

Browse files
authored
fix: do not register close hook if websocket is disabled (#3474)
1 parent 6cc9997 commit 9edcc8f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/utils/dev.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export async function startSocketServer(nuxt: Nuxt, options: ModuleOptions, mani
4040

4141
listener.server.on('upgrade', websocket.serve)
4242
})
43+
44+
nuxt.hook('close', async () => {
45+
// Close WebSocket server
46+
await websocket?.close()
47+
await listener?.server?.close()
48+
})
4349
}
4450

4551
async function broadcast(collection: ResolvedCollection, key: string, insertQuery?: string[]) {
@@ -76,12 +82,6 @@ export async function startSocketServer(nuxt: Nuxt, options: ModuleOptions, mani
7682
})
7783
}
7884

79-
nuxt.hook('close', async () => {
80-
// Close WebSocket server
81-
await websocket?.close()
82-
await listener.server.close()
83-
})
84-
8585
return {
8686
broadcast,
8787
}

0 commit comments

Comments
 (0)