1'use strict'; 2const common = require('../common'); 3const { Resolver } = require('dns'); 4const dgram = require('dgram'); 5const { Worker, isMainThread } = require('worker_threads'); 6 7// Test that Workers can terminate while DNS queries are outstanding. 8 9if (isMainThread) { 10 return new Worker(__filename); 11} 12 13const socket = dgram.createSocket('udp4'); 14 15socket.bind(0, common.mustCall(() => { 16 const resolver = new Resolver(); 17 resolver.setServers([`127.0.0.1:${socket.address().port}`]); 18 resolver.resolve4('example.org', common.mustNotCall()); 19})); 20 21socket.on('message', common.mustCall(() => { 22 process.exit(); 23})); 24