{"action":"created","issue":{"url":"https://api.github.com/repos/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/108","labels_url":"https://api.github.com/repos/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/108/comments","events_url":"https://api.github.com/repos/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/108/events","html_url":"https://github.com/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/108","id":115968676,"number":108,"title":"Gulp watch race condition","user":{"login":"reneolivo","id":1642119,"avatar_url":"https://avatars.githubusercontent.com/u/1642119?v=3","gravatar_id":"","url":"https://api.github.com/users/reneolivo","html_url":"https://github.com/reneolivo","followers_url":"https://api.github.com/users/reneolivo/followers","following_url":"https://api.github.com/users/reneolivo/following{/other_user}","gists_url":"https://api.github.com/users/reneolivo/gists{/gist_id}","starred_url":"https://api.github.com/users/reneolivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reneolivo/subscriptions","organizations_url":"https://api.github.com/users/reneolivo/orgs","repos_url":"https://api.github.com/users/reneolivo/repos","events_url":"https://api.github.com/users/reneolivo/events{/privacy}","received_events_url":"https://api.github.com/users/reneolivo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jakemmarsh/angularjs-gulp-browserify-boilerplate/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-09T21:19:47Z","updated_at":"2015-11-10T00:46:40Z","closed_at":null,"body":"When you update a stylesheet and the operation takes one or two seconds the browser reloads before the stylesheet is processed. This causes the browser to reload with the previous changes.\r\n\r\nI'm guessing the problem applies to all other watch sequences, but I have only experienced it with the styles."},"comment":{"url":"https://api.github.com/repos/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/comments/155247327","html_url":"https://github.com/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/108#issuecomment-155247327","issue_url":"https://api.github.com/repos/jakemmarsh/angularjs-gulp-browserify-boilerplate/issues/108","id":155247327,"user":{"login":"reneolivo","id":1642119,"avatar_url":"https://avatars.githubusercontent.com/u/1642119?v=3","gravatar_id":"","url":"https://api.github.com/users/reneolivo","html_url":"https://github.com/reneolivo","followers_url":"https://api.github.com/users/reneolivo/followers","following_url":"https://api.github.com/users/reneolivo/following{/other_user}","gists_url":"https://api.github.com/users/reneolivo/gists{/gist_id}","starred_url":"https://api.github.com/users/reneolivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reneolivo/subscriptions","organizations_url":"https://api.github.com/users/reneolivo/orgs","repos_url":"https://api.github.com/users/reneolivo/repos","events_url":"https://api.github.com/users/reneolivo/events{/privacy}","received_events_url":"https://api.github.com/users/reneolivo/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T00:46:40Z","updated_at":"2015-11-10T00:46:40Z","body":"That didn't help me at all anyway because gulp tasks run in parallel, not in sequence (at least not by default). \r\n\r\nI have been doing several tests and I think I found the culprit: `browserSync.stream({once: true});`. More specifically `{once: true}`.\r\n\r\nI'm not sure if I understand it well (the documentation is not clear), but it seems that `{once: true}` is so that when all the tasks run they don't call the reload method a bunch of times, and I don't know what's going on internally, but that makes browserSync reload the browser before the task is completed. For example:\r\n\r\n```\r\n[20:31:12] Starting 'styles'...\r\n[20:31:12] Starting 'reload-browser'...\r\n[BS] Reloading Browsers...\r\n[20:31:12] Finished 'reload-browser' after 1.01 ms\r\n[20:31:16] Finished 'styles' after 3.3 s\r\n```\r\n\r\nNo `{once: true}`:\r\n\r\n```\r\n[20:37:09] Starting 'styles'...\r\n[BS] 1 file changed (main.css)\r\n[20:37:12] Finished 'styles' after 3 s\r\n```\r\n\r\nCool thing is: it doesn't even do a full reload!!! It just changed the CSS files on the fly.\r\n\r\nAgain: I think the `{once: true}` is there to stop piling up too many reloads at the same time, but I don't think removing it is going to be an issue (not 100% sure) since those tasks (styles, views, images, etc.) run before browserSync is started"}}