in src/http/httpProxy.ts [144:169]
function tryPort(port: number) {
if (port > maxPort) {
// If we've reached the maximum port, throw an error
throw new AzFuncSystemError(
`No available ports found between ${minPort} and ${maxPort}. To enable HTTP streaming, please open a port in this range.`
);
}
server.once('error', () => {
// If the port is unavailable, increment and try the next one
tryPort(port + 1);
});
// If the port is available, return it
server.once('listening', () => {
const address = server.address();
if (address !== null && typeof address === 'object') {
port = address.port;
server.close();
callback(port);
}
});
// Try binding to the given port
server.listen(port);
}