question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BrowserSync couldn’t exit a Gulp task if there’s a server configured

See original GitHub issue

Details

I’m trying to run a local server and take a screenshot of a page using pageres, but BrowserSync couldn’t exit() a Gulp task if there’s a server configured.

Steps to reproduce

  1. npm install gulp pageres browser-sync
  2. touch gulpfile.js with contents below
  3. gulp one and gulp two, compare results
const gulp = require('gulp');
const pageres = require('pageres');
const sync = require('browser-sync').create();

gulp.task('server-one', () => {
    sync.init();
});

gulp.task('server-two', () => {
    sync.init({
        server: {
            baseDir: '.'
        }
    });
});

gulp.task('pageres', () => {
    return new pageres()
        .src('localhost:3000', ['1024x640'], {
            crop: true,
            scale: 2,
            filename: 'localhost'
        })
        .dest('.')
        .run()
        .then(() => sync.exit());
});

gulp.task('one', ['server-one', 'pageres']);
gulp.task('two', ['server-two', 'pageres']);

The only difference between one and two is

server: {
    baseDir: '.'
}

But in two case BS doesn’t exit task.

Versions

  • Browsersync 2.11.2
  • Node v5.10.0
  • Npm v3.8.3

Affected platforms

  • OS X

Use-case

  • Gulp

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
shakyShanecommented, Oct 29, 2016

This is actually an issue with the socket.io server. Once a browser is connected even a single time, the tear-down logic within socket.io or engine.io is not running as expected. You can prove the by running Browsersync with open:false and then calling bs.exit() after a few seconds. On Sat, 29 Oct 2016 at 11:50, tcme notifications@github.com wrote:

do you use bs.watch somewhere? In my case the process does not exit if I use bs.watch see #1222 https://github.com/BrowserSync/browser-sync/issues/1222

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BrowserSync/browser-sync/issues/1052#issuecomment-257084753, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkUAo1Bwjd5Bwhmm51C86vPFnG41-p_ks5q4yT8gaJpZM4ICm4o .

0reactions
IgnusGcommented, Jun 1, 2018

I’m running into the same problem. I presume it was never fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Browsersync options
These are all the options that you can configure when using Browsersync. Create a single object and pass it as the first argument...
Read more >
browserSync.reload doesn't execute using Gulp task
I found out that if I put gulp task 'start-server' in 'watch-sass.js' file instead of separating it to his own file, it works....
Read more >
Gulp v4 - Sass and BrowserSync setup - YouTube
In this video I look at how we can setup a gulp build that will compile Sass for us, and automatically sync all...
Read more >
How to Wire Up Ruby on Rails and AngularJS as a Single ...
I've tried to do Angular projects with full-blown Rails, but I end up with ... If you have a Rails server running on...
Read more >
BrowserSync/browser-sync - Gitter
Using gulp-nodemon with browser-sync Some people want to use browser-sync. That's totally fine, just start browser sync in the same task as nodemon({})...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found