Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reload randomly not working after successfully trigger watch #11

Open
zigotica opened this issue Oct 18, 2012 · 8 comments
Open

reload randomly not working after successfully trigger watch #11

zigotica opened this issue Oct 18, 2012 · 8 comments

Comments

@zigotica
Copy link

Hi

I have a problem with reload task, it randomly works or not. Here is the relevant parts of my grunt file:

server: {
      port: 8000,
      base: '.'
    },
    reload: {
      port: 6001,
      proxy: {
        host: 'localhost'
      }
    },
    watch:{
      files:['*.html', 'sources/compass/*.scss', 'sources/js/*.js'],
      tasks:'default reload'
    }
  });

  var connect = require('connect');

  // load npm tasks.
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-reload');

  // Register tasks.
  grunt.registerTask('default', 'lint concat min sass');
  grunt.registerTask('live', 'server reload watch');

When i run grunt live sometimes it works perfect, sometimes it does not reload after changes have been made (watch runs ok, but it just fails to reload the browser)

Running "server" task
Starting static web server on port 8000.

Running "reload" task
Proxying http://localhost:8000/
reload server running at http://localhost:6001

Running "watch" task
Waiting...OK
>> File "sources/js/main.js" changed.

Running "lint:files" (lint) task
Lint free.

Running "concat:dist" (concat) task
File "sources/js/app.js" created.

Running "min:dist" (min) task
File "public/js/app.min.js" created.
Uncompressed size: 33387 bytes.
Compressed size: 7243 bytes gzipped (18814 bytes minified).

Running "sass:dist" (sass) task

Running "reload" task
File updated. Reload triggered.

Running "watch" task
Waiting...

As you can see the message for the "reload" task says File updated. Reload triggered. but it does not reload page in browser. Randomly.

I would appreciate any help.

@cesutherland
Copy link

I experience this if I save multiple times quickly. The first save will refresh the page, and subsequent saves won't. In my case I can see that the websocket is not yet open, and that's why the page does not refresh. Maybe it is the same case for you?

@zigotica
Copy link
Author

zigotica commented Nov 8, 2012

yep, in some cases it does not include de js in the page… weird

@cesutherland
Copy link

So I see this line in the client code:
https://github.com/webxl/grunt-reload/blob/master/tasks/include/reloadClient.js#L48

That 3 second delay is what causes the WS to open late. Any speculation as to why it's there?

@manuel-woelker
Copy link
Contributor

Another culprit might be this server side throttling
https://github.com/webxl/grunt-reload/blob/master/tasks/reload.js#L61
replacing the throttle with a debounce might do the trick.

cf. http://benalman.com/projects/jquery-throttle-debounce-plugin/

@zigotica
Copy link
Author

thank you guys, i'll have a look at both

@zigotica
Copy link
Author

thank you @cesutherland and @manuel-woelker
Tried what you suggested but I finally quit using the default proxy since it was not creating the websocket whatsoever.
Then I installed LiveReload, and now it works like a charm.

@cesutherland
Copy link

I haven't been having any trouble since removing that timeout. I had a
little trouble with the web sockets at first (there are two ports to
configure, which was a little confusing).

On Sat, Dec 22, 2012 at 10:18 AM, Sergi Meseguer
[email protected]:

thank you @cesutherland https://github.com/cesutherland and
@manuel-woelker https://github.com/manuel-woelker
Tried what you suggested but I finally quit using the default proxy since
it was not creating the websocket whatsoever.
Then I installed LiveReload, and now it works like a charm.


Reply to this email directly or view it on GitHubhttps://github.com//issues/11#issuecomment-11638042.

@zigotica
Copy link
Author

@cesutherland been trying what you guys suggested, in all combinations, with no luck, that's why i finally installed LiveReload. Thanx again, anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants