refactor(net): remove use of as Deno.NetAddr (#4574)

This commit is contained in:
Asher Gomez 2024-04-15 16:47:28 +10:00 committed by GitHub
parent bfefdd713d
commit dd55f2801c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,7 +25,7 @@ export function getAvailablePort(options?: GetAvailablePortOptions): number {
try {
// Check if the preferred port is available
using listener = Deno.listen({ port: options.preferredPort });
return (listener.addr as Deno.NetAddr).port;
return listener.addr.port;
} catch (e) {
// If the preferred port is not available, fall through and find an available port
if (!(e instanceof Deno.errors.AddrInUse)) {
@ -35,5 +35,5 @@ export function getAvailablePort(options?: GetAvailablePortOptions): number {
}
using listener = Deno.listen({ port: 0 });
return (listener.addr as Deno.NetAddr).port;
return listener.addr.port;
}