xref: /third_party/node/test/parallel/test-worker-dns-terminate-during-query.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst { Resolver } = require('dns');
41cb0ef41Sopenharmony_ciconst dgram = require('dgram');
51cb0ef41Sopenharmony_ciconst { Worker, isMainThread } = require('worker_threads');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// Test that Workers can terminate while DNS queries are outstanding.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciif (isMainThread) {
101cb0ef41Sopenharmony_ci  return new Worker(__filename);
111cb0ef41Sopenharmony_ci}
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst socket = dgram.createSocket('udp4');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_cisocket.bind(0, common.mustCall(() => {
161cb0ef41Sopenharmony_ci  const resolver = new Resolver();
171cb0ef41Sopenharmony_ci  resolver.setServers([`127.0.0.1:${socket.address().port}`]);
181cb0ef41Sopenharmony_ci  resolver.resolve4('example.org', common.mustNotCall());
191cb0ef41Sopenharmony_ci}));
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_cisocket.on('message', common.mustCall(() => {
221cb0ef41Sopenharmony_ci  process.exit();
231cb0ef41Sopenharmony_ci}));
24

Indexes created Thu Nov 07 10:32:03 CST 2024