{"action":"created","issue":{"url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/511","labels_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/511/labels{/name}","comments_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/511/comments","events_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/511/events","html_url":"https://github.com/BrowserSync/browser-sync/issues/511","id":60598853,"number":511,"title":"Emitter Error on Reload with Multiple Instances","user":{"login":"rwagner00","id":1789035,"avatar_url":"https://avatars.githubusercontent.com/u/1789035?v=3","gravatar_id":"","url":"https://api.github.com/users/rwagner00","html_url":"https://github.com/rwagner00","followers_url":"https://api.github.com/users/rwagner00/followers","following_url":"https://api.github.com/users/rwagner00/following{/other_user}","gists_url":"https://api.github.com/users/rwagner00/gists{/gist_id}","starred_url":"https://api.github.com/users/rwagner00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwagner00/subscriptions","organizations_url":"https://api.github.com/users/rwagner00/orgs","repos_url":"https://api.github.com/users/rwagner00/repos","events_url":"https://api.github.com/users/rwagner00/events{/privacy}","received_events_url":"https://api.github.com/users/rwagner00/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BrowserSync/browser-sync/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-11T01:58:09Z","updated_at":"2015-03-17T08:18:13Z","closed_at":"2015-03-13T16:05:35Z","body":"Operating System: OSX 10.9.5 \r\nNodeJS Version: v0.12.0\r\nNPM Version: 2.5.1\r\nBrowserSync Version: 2.2.3\r\n\r\nGulpfile Contents: \r\n```js\r\nvar gulp = require('gulp');\r\nvar compass = require('gulp-compass');\r\nvar notify = require(\"gulp-notify\");\r\nvar plumber = require(\"gulp-plumber\");\r\nvar cp = require('child_process');\r\nvar browserSync = require('browser-sync');\r\nvar bs1 = browserSync.create(\"proxy1\");\r\nvar bs2 = browserSync.create(\"proxy2\");\r\n\r\nvar messages = {\r\n  jekyllBuild: '<span style=\"color: grey\">Running:</span> $ jekyll build'\r\n};\r\n\r\n/**\r\n * Build the Jekyll Site\r\n */\r\ngulp.task('jekyll-build', function (done) {\r\n  browserSync.notify(messages.jekyllBuild);\r\n  return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})\r\n    .on('close', done);\r\n});\r\n\r\n/**\r\n * Rebuild Jekyll & do page reload\r\n */\r\ngulp.task('jekyll-rebuild', ['jekyll-build'], function () {\r\n  browserSync.reload();\r\n});\r\n\r\n/**\r\n * Wait for jekyll-build, then launch the Server\r\n */\r\ngulp.task('browser-sync', function () {\r\n  bs1.init({\r\n    server: {\r\n      baseDir: '_site'\r\n    },\r\n    port: 3010,\r\n    ui: {\r\n      port: 3011\r\n    }\r\n  });\r\n  bs2.init({\r\n    server: {\r\n      baseDir: '_site'\r\n    },\r\n    port: 3012,\r\n    ui: {\r\n      port: 3013\r\n    }\r\n  });\r\n});\r\n\r\n\r\n// Calls Compass and Watch when gulp is run.\r\ngulp.task('default', ['browser-sync', 'compass', 'jekyll-build', 'watch']);\r\n\r\n// Compass compilation function.\r\ngulp.task('compass', function () {\r\n  var onError = function (err) {\r\n    notify.onError({\r\n      title: \"Compass\",\r\n      subtitle: \"Compilation Failure!\",\r\n      message: \"Error: <%= error.message %>\"\r\n    })(err);\r\n    this.emit('end');\r\n  };\r\n\r\n  return gulp.src('_sass/*.scss')\r\n    .pipe(plumber({errorHandler: onError}))\r\n    .pipe(compass({\r\n      css: '_site/css',\r\n      sass: '_sass',\r\n      bundle_exec: 'true',\r\n      debug: 'true'\r\n    }))\r\n    .pipe(bs1.reload({stream: true}))\r\n    .pipe(notify({\r\n      title: 'Compass',\r\n      subtitle: 'Success',\r\n      message: 'Compass successfully compiled!'\r\n    }))\r\n    // This is a workaround to needing to have the compiled CSS in both the\r\n    // css/ and _site/css folder in order to make live reload function.\r\n    // Ideally, Jekyll will be reconfigured to not expect to have css in both\r\n    // places.\r\n    .pipe(gulp.dest('css'));\r\n});\r\n\r\n/**\r\n * Watch scss files for changes & recompile\r\n * Watch html/md files, run jekyll & reload BrowserSync\r\n */\r\ngulp.task('watch', function () {\r\n  gulp.watch('_sass/*.scss', ['compass']);\r\n  gulp.watch(['index.html', '_layouts/*.html', '_posts/*', '_includes/*.html'], ['jekyll-rebuild']);\r\n  gulp.watch('_site/js/*.js', browserSync.reload);\r\n});\r\n\r\n```\r\n\r\nError experience: When I run the default Gulp task, two windows open and both report that they are connected to BrowserSync. I can confirm this behavior by removing reload from the default Compass process and calling `bs1.notify('bs1');` and `bs2.notify('bs2);`, which output to the correct windows. However, whenever I attempt to call bs1.reload() in any way, the reload fails with the below error message.\r\n\r\nError Message: \r\n[21:42:15] Using gulpfile ~/Sites/project/gulpfile.js\r\n[21:42:15] Starting 'browser-sync'...\r\n[21:42:15] Finished 'browser-sync' after 15 ms\r\n[21:42:15] Starting 'compass'...\r\n[21:42:15] Starting 'jekyll-build'...\r\n[21:42:15] Starting 'watch'...\r\n[21:42:15] Finished 'watch' after 22 ms\r\n[21:42:15] gulp-compass: Running command: /usr/bin/bundle exec compass compile /Users/wagner/Sites/project /Users/wagner/Sites/project/_sass/main.scss --no-line-comments --relative-assets --debug-info --css-dir _site/css --sass-dir _sass\r\n[BS] Access URLs:\r\n ------------------------------------\r\n       Local: http://localhost:3010\r\n    External: http://192.168.1.6:3010\r\n ------------------------------------\r\n          UI: http://localhost:3011\r\n UI External: http://192.168.1.6:3011\r\n ------------------------------------\r\n[BS] Serving files from: _site\r\n[BS] Access URLs:\r\n ------------------------------------\r\n       Local: http://localhost:3012\r\n    External: http://192.168.1.6:3012\r\n ------------------------------------\r\n          UI: http://localhost:3013\r\n UI External: http://192.168.1.6:3013\r\n ------------------------------------\r\n[BS] Serving files from: _site\r\nConfiguration file: /Users/wagner/Sites/project/_config.yml\r\n            Source: /Users/wagner/Sites/project\r\n       Destination: /Users/wagner/Sites/project/_site\r\n      Generating... \r\n/Users/wagner/Sites/project/node_modules/browser-sync/lib/public/reload.js:14\r\n        emitter.emit(\"file:changed\", {\r\n               ^\r\nTypeError: Cannot read property 'emit' of undefined\r\n    at emitReload (/Users/wagner/Sites/project/node_modules/browser-sync/lib/public/reload.js:14:16)\r\n    at Transform.reload._transform (/Users/wagner/Sites/project/node_modules/browser-sync/lib/public/reload.js:72:29)\r\n    at Transform._read (_stream_transform.js:179:10)\r\n    at Transform._write (_stream_transform.js:167:12)\r\n    at doWrite (_stream_writable.js:301:12)\r\n    at writeOrBuffer (_stream_writable.js:288:5)\r\n    at Transform.Writable.write (_stream_writable.js:217:11)\r\n    at write (/Users/wagner/Sites/project/node_modules/gulp-compass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)\r\n    at flow (/Users/wagner/Sites/project/node_modules/gulp-compass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)\r\n    at DestroyableTransform.pipeOnReadable (/Users/wagner/Sites/project/node_modules/gulp-compass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)\r\n\r\nProcess finished with exit code 1\r\n"},"comment":{"url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/comments/82196443","html_url":"https://github.com/BrowserSync/browser-sync/issues/511#issuecomment-82196443","issue_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/511","id":82196443,"user":{"login":"shakyShane","id":1643522,"avatar_url":"https://avatars.githubusercontent.com/u/1643522?v=3","gravatar_id":"","url":"https://api.github.com/users/shakyShane","html_url":"https://github.com/shakyShane","followers_url":"https://api.github.com/users/shakyShane/followers","following_url":"https://api.github.com/users/shakyShane/following{/other_user}","gists_url":"https://api.github.com/users/shakyShane/gists{/gist_id}","starred_url":"https://api.github.com/users/shakyShane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shakyShane/subscriptions","organizations_url":"https://api.github.com/users/shakyShane/orgs","repos_url":"https://api.github.com/users/shakyShane/repos","events_url":"https://api.github.com/users/shakyShane/events{/privacy}","received_events_url":"https://api.github.com/users/shakyShane/received_events","type":"User","site_admin":false},"created_at":"2015-03-17T08:18:12Z","updated_at":"2015-03-17T08:18:12Z","body":":+1: \r\n"}}