Hi,
Is there a way to hot reload a TCP server without dropping clients connection?
I have tried the following:
// server.ts
export class Server {
open = async (socket: Socket) => {
console.log('changes here') // not reflected if I change this string
}
}
// index.ts
declare global {
var socket: TCPSocketListener<undefined>
}
globalThis.socket ??= Bun.listen({
hostname: 'localhost',
port: 25565,
socket: new Server(),
})
// terminal
$ bun --bun --hot run index.ts
And while changes are detected fine, they are not applied... It works fine with --watch, but it also disconnects clients.
I have also tried to add the new Server() to globalThis but nothing changes
Thanks for your help!