Files
bun.sh/test/js/node/async_hooks/async-context/async-context-dns-reverse.js
2025-07-02 17:45:00 -07:00

15 lines
425 B
JavaScript

const { AsyncLocalStorage } = require("async_hooks");
const dns = require("dns");
const asyncLocalStorage = new AsyncLocalStorage();
asyncLocalStorage.run({ test: "dns.reverse" }, () => {
dns.reverse("8.8.8.8", (err, hostnames) => {
if (asyncLocalStorage.getStore()?.test !== "dns.reverse") {
console.error("FAIL: dns.reverse callback lost context");
process.exit(1);
}
process.exit(0);
});
});