Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

442 B
Raw Blame
import { createServer } from 'node:net';

// A fixed port collides with other test runs and dev servers on the same machine, so tests ask the system for a free one.
export function freePort() {
  return new Promise((resolve, reject) => {
    const probe = createServer();
    probe.once('error', reject);
    probe.listen(0, '127.0.0.1', () => {
      const { port } = probe.address();
      probe.close(() => resolve(port));
    });
  });
}