Skip to content

When watching files calling server.cleanup() does not properly shut down #855

@patrickarlt

Description

@patrickarlt

I've been running into an issue in some tests for a project where browser sync is keeping the tests open even after I call server.cleanup(). I've managed to reproduce this behavior with this super simple snippet.

var server = require('browser-sync').create();

server.emitter.on('init', function () {
  process.nextTick(function () {
    server.cleanup();
  });
});

server.init({
  logLevel: 'debug',
  server: 'site',
  files: 'site/**/*',  // if files is passed the process never exists because the file watcher keeps running
  open: false
});

Digging through the source it looks like the issue is on https://github.com/BrowserSync/browser-sync/blob/master/lib/file-watcher.js#L34 and https://github.com/BrowserSync/browser-sync/blob/master/lib/file-watcher.js#L74. I tried registering watcher.close with bs.registerCleanupTask but it still doesn't exit the process properly.

Is there any chance you could take a look at this issue?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions