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

Sometimes work, sometimes don't : timeout issues ? #3

Closed
DjebbZ opened this issue Dec 5, 2012 · 12 comments
Closed

Sometimes work, sometimes don't : timeout issues ? #3

DjebbZ opened this issue Dec 5, 2012 · 12 comments

Comments

@DjebbZ
Copy link

DjebbZ commented Dec 5, 2012

Hi,

I decided to try the plugin, and after adding 2 blocks for scripts and styles like this @getBlock('styles').add(['my','styles']).toHTML(), I launched docpad run. The problem is that the plugin sometimes managed to reload the page after a change, sometimes dont'.

I don't know how to debug WebSockets stuff in the browser (Chrome), the Network panel just shows a pending connection, sometimes for as long as 30s - that is, until I change the file again to see if something will happen.

Here's the output of the docpad run command :

docpad run
info: Welcome to DocPad v6.17.3
info: Plugins: coffee, eco, less, livereload, marked
info: Environment: development
info: DocPad listening to http://localhost:9778/ on directory /Users/khalid_jebbari/Documents/Projects/Buro2/site/out
   info  - socket.io started
info: Generating...
info: Generated all 8 files in 0.746 seconds
info: Watching setup starting...
info: Watching setup
info: The action completed successfully

I change a file (just adding a 's'). It works fine :

info: Regenerating at 13:18:59
info: Generating...
info: Generated 4 files in 0.305 seconds
info: Regenerated at 13:18:59

I change again (add another 's'). Same output but no reload in the browser :

info: Regenerating at 13:19:18
info: Generating...
info: Generated 4 files in 0.369 seconds
info: Regenerated at 13:19:19

Then after almost 1 minute, without me changing anything in the source, new debug output appears in the console :

   debug - client authorized
   info  - handshake authorized QsMBc9nUsogzFeJ9ASBX
   debug - setting request GET /socket.io/1/xhr-polling/QsMBc9nUsogzFeJ9ASBX?t=1354710006082
   debug - setting poll timeout
   debug - client authorized for 
   debug - clearing poll timeout
   debug - xhr-polling writing 1::
   debug - set close timeout for client QsMBc9nUsogzFeJ9ASBX
   debug - xhr-polling received data packet 1::/docpad-live-reload
   debug - client authorized for /docpad-live-reload
   debug - setting request GET /socket.io/1/xhr-polling/QsMBc9nUsogzFeJ9ASBX?t=1354710006098
   debug - setting poll timeout
   debug - clearing poll timeout
   debug - xhr-polling writing 1::/docpad-live-reload
   debug - set close timeout for client QsMBc9nUsogzFeJ9ASBX
   debug - discarding transport
   debug - cleared close timeout for client QsMBc9nUsogzFeJ9ASBX

And this output keeps appearing in a kind of infinite loop at a slow rate. Reading it there's seem to be some problem with the connexion and timeouts that prevent stuff from working, but I can't really say more.

@balupton
Copy link
Member

Try with the latest version (v2.3.0) I've done a bunch of improvements here.

I've also noticed that this infinite loop thing will occur if your app is already socket.io. In which case use the new getSocket option to make your app's socket available to livereload.

@kartast
Copy link

kartast commented Apr 10, 2013

I am on latest version (v2.3.1) and I meet a bug.
Basically it will only reload for the first change of every file.

on file a, I change something, and save, it worked.
on file a, I change again, and save, not work.

on file b, I change something, and save, it generate again.
on file b, i change again, and save, doesn't work again.

@balupton
Copy link
Member

Hey @kartast can you try reinstalling DocPad, I just pushed some changes up right then that should fix this. Let me know if you still get it. By the way, what editor are you using to edit your files?

@kartast
Copy link

kartast commented Apr 10, 2013

Hi @balupton.. i reinstalled and it still doesn't work. I am using SublimeText 3.

It turns out, if I use BBEdit it works well.

So for now I can use other text editor to work with this.

Thanks!

@balupton
Copy link
Member

Hrmm. Mind if I remote in and see if I can fix it?

@kartast
Copy link

kartast commented Apr 10, 2013

It works with Sublime Text 2 too.. I think you can reproduce it easily with Sublime Text 3..

It throws this:

Error: ENOENT, stat '/Users/karta022/Google Drive/Dropbox/karzy.io/src/documents/posts/.subl88d.tmp'

Not sure if it helps

@vjpr
Copy link
Contributor

vjpr commented May 3, 2013

I am having the same problem.

Strangely, if I set a breakpoint on the inject() method, it always works. If I don't, it doesn't work.

@balupton
Copy link
Member

balupton commented May 3, 2013

Hrmmm... try the suggestions at the bottom of the https://github.com/bevry/watchr readme, do they help?

@vjpr
Copy link
Contributor

vjpr commented May 3, 2013

I changed async=true to defer=true in livereload.plugin.js and it seems to have fixed it.

Can't really work out what was going wrong though.

@vjpr
Copy link
Contributor

vjpr commented May 3, 2013

Actually that didn't fix it.

@vjpr
Copy link
Contributor

vjpr commented May 3, 2013

Ok I think I've fixed it now.

The problem was that inject() was being called when document.readystate was 'loading'. It appears you cannot set event handlers before the page has loaded.

Replacing the call to inject with this code fixes it.

var readyStateCheckInterval = setInterval(function() {
    if (document.readyState === "complete") {
        inject();
        clearInterval(readyStateCheckInterval);
    }
}, 10);

From http://stackoverflow.com/a/7088499/130910

@balupton
Copy link
Member

balupton commented May 3, 2013

Awesome, great work! :) Want to send it through as a pull request? And I'll get a new version out pronto.

balupton added a commit that referenced this issue May 6, 2013
Fixes #3. Wait until page is loaded before injecting socket.io script.
balupton added a commit that referenced this issue May 6, 2013
- v2.4.0 May 6, 2013
	- Merged [pull request
#7](#7) by
[Vaughan Rouesnel](https://github.com/vjpr) to solve [issue
#3](#3)
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

4 participants