Find the DNS correctness bugs in this generated endpoint lookup.
JavaScript
import { promises as dns } from "node:dns";
const cache = new Map();
export async function endpoint(hostname) {
if (cache.has(hostname)) return cache.get(hostname);
try {
const [address] = await dns.resolve4(hostname);
cache.set(hostname, address);
return address;
} catch {
return null;
}
}