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

Weird issue with concurrent requests and event callbacks #51

Closed
cjroebuck opened this issue May 14, 2013 · 2 comments
Closed

Weird issue with concurrent requests and event callbacks #51

cjroebuck opened this issue May 14, 2013 · 2 comments

Comments

@cjroebuck
Copy link

Hey @lawnsea, first of all - thanks a lot for SpookyJS.

I'm having an issue when using Spooky on different URLs in parallel. I want to capture a screenshot of urls A, B and C

I set up spooky and listen on the capture.saved casper event. The problem is if I call spooky with url A, then straight away call spooky with url B, and then url C, whenever the first url is finished rendering to a file, I get THREE 'capture.saved' events.. all calling back with the same image of the first url to have finished rendering, even though only ONE url has been captured. Then later on.. I will get TWO more 'capture.saved' events for the remaining urls in whatever order the requests finish. These last events call back with the correct image for the url.

I've put together a simple gist which can be run that demonstrates the issue: https://gist.github.com/cjroebuck/5580502

Hopefully this is something stupid I am doing and there's a simple workaround as its been driving me nuts.. thanks

@lawnsea
Copy link
Contributor

lawnsea commented May 16, 2013

Huh. That's odd. I'll look into it. Thanks for the report!

@tomchentw
Copy link

The reason is wrong prototype chain used in Spooky. This bug costs me few hours to solve. I'll fill a PR.

Updated:
#60

@lawnsea lawnsea closed this as completed in 0175e2c Jun 8, 2013
jeresig pushed a commit to jeresig/SpookyJS that referenced this issue Jun 27, 2013
Previously, the constructor did not pass new instances through EventEmitter, so
all Spooky instances shared the same EventEmitter instance state. Instead, use
util.inherits and call EventEmitter when constructing Spooky instances.

Thanks to @tomchentw for figuring this one out.

Close SpookyJS#51, SpookyJS#60
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