tristandunn / pusher-fake

A fake Pusher server for development and testing.
https://rubygems.org/gems/pusher-fake
MIT License
173 stars 32 forks source link

Timeout after update #35

Closed strika closed 9 years ago

strika commented 9 years ago

Recently we did a major update of Pusher and Pusher Fake on a project. Everything works great in production, but we have problems in tests:

I tried to debug the issue and it looks like after a connection from browser to Pusher Fake server is established, browser becomes unresponsive to tests.

It's possible that the test passes on Semaphore CI since it's faster than a development machine.

Did you experience similar issues? Any advice for debugging?

Thanks.

tristandunn commented 9 years ago

I haven't experienced anything that consistent, but Timeout tests usually end up being pretty brittle. I'm not sure I can help without more details. Library versions? Which test framework and browser? Does increasing the timeout? And most importantly can you provide a code example, preferably an isolated version to recreate the issue?

strika commented 9 years ago

We upgraded Pusher Fake from 0.1.3 to 1.2.0. We're using Cucumber, Capybara and Selenium.

I wasn't able to create an isolated example. We have a code like this (for debugging purposes):

channel = pusher.subscribe(...)
channel.bind_all (data) ->
  if data == "pusher:subscription_succeeded"
    $("body").append("Pusher connection established")

I notice that it takes 7-9 seconds for "Pusher connection established" to appear. I tried to fake this lag with sleep and it looks like there's not Timeout when lag is shorter than 5s.

Also, the lag doesn't present problem on other pages (without Pusher). There, even if I add sleep 15, tests continue as usual. On the page with Pusher, when there is sleep longer than 5s, it Timeouts.

I believe that this lag (for connection to get established) is shorter on Semaphore CI, so it passes. So making sure this lag is shorter could fix the problem for us. Do you know why does it take so long to connect to Pusher Fake server? And how can we make it faster? Thanks.

tristandunn commented 9 years ago

Have you tried enabling verbose logging for pusher-fake to see if the delay is with sending and receiving the event or actually getting to to the point of sending the event?

I haven't used the library with Selenium in a while, but if it's not too difficult would you mind trying poltergeist or capybara-webkit, if the verbose logging doesn't give any clues? Assume you're not using a headless version as CI is, which may be slower, but 7 to 9 seconds seems rather high.

strika commented 9 years ago

@tristandunn We were able to trace the issue back to a JavaScript race condition. Verbose logging was very helpful. It might be good idea to add that to the Readme or wiki. Thanks for your support and for the awesome library.

Cheers.

tristandunn commented 9 years ago

Glad to hear. I added configuration information to the README in c979bb0a30ce449007c75b8afb68c07dc9441dba.