Skip to content

Interval in sleep.js seems to keep the process alive #10

@jaller94

Description

@jaller94

I am using Node v10.11.0.

I’ve seen that the interval in sleep.js is unref()ed to allow the process to end, however, this does not seem to work for me.

Minimal code to reproduce

const dnssd = require('dnssd');
const ad = new dnssd.Advertisement(dnssd.tcp('http'), 4321);
console.log('starting...');
ad.start();
console.log('started');
console.log('stopping...');
ad.stop(false, (err) => {
  if (err) throw err;
  console.log('stopped');
});

When running this script, the process will not exit for me.

How I came to this observation

I use webthing which uses dnssd via NPM.

After completing tests in a repository of mine Jest has to be force exited for the process to quit.

git clone git@gitlab.com:webthings/all-webthings.git
cd all-webthings
git checkout cf92a899d376ca48411b56f04ca0c2915a41d2ba
npm test -- --detectOpenHandles

This output the following on my machine:

Ran all test suites.

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  Timeout

      at Object.<anonymous> (node_modules/dnssd/lib/sleep.js:14:16)
      at Object.<anonymous> (node_modules/dnssd/lib/Advertisement.js:14:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions