MCPcopy Index your code
hub / github.com/coder/coder / waitForPort

Function waitForPort

site/e2e/helpers.ts:881–898  ·  view source on GitHub ↗
(
	port: number,
	host = "0.0.0.0",
	timeout = 60_000,
)

Source from the content-addressed store, hash-verified

879};
880
881async function waitForPort(
882 port: number,
883 host = "0.0.0.0",
884 timeout = 60_000,
885): Promise<void> {
886 const start = Date.now();
887 while (Date.now() - start < timeout) {
888 const available = await isPortAvailable(port, host);
889 if (available) {
890 return;
891 }
892 console.warn(`${host}:${port} is in use, checking again in 1s`);
893 await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait 1 second before retrying
894 }
895 throw new Error(
896 `Timeout: port ${port} is still in use after ${timeout / 1000} seconds.`,
897 );
898}
899
900function isPortAvailable(port: number, host = "0.0.0.0"): Promise<boolean> {
901 return new Promise((resolve) => {

Callers 1

createServerFunction · 0.85

Calls 2

isPortAvailableFunction · 0.85
nowMethod · 0.45

Tested by

no test coverage detected