async function start_server(handler) {
			if (server) {
				throw new Error('server already started');
			}
			server = http.createServer(handler);

			await new Promise((fulfil) => {
				server.listen(0, 'localhost', () => {
					fulfil(undefined);
				});
			});

			const { port } = /** @type {import('net').AddressInfo} */ (server.address());
			if (!port) {
				throw new Error(`Could not find port from server ${JSON.stringify(server.address())}`);
			}
			sockets = new Set();
			server.on('connection', (socket) => {
				sockets.add(socket);
				socket.on('close', () => {
					sockets.delete(socket);
				});
			});
			return {
				port
			};
		}
@param {(req: http.IncomingMessage, res: http.ServerResponse) => void} handler