Hi list,

I think I've discovered a race condition in the pubsub code which is kind of funny as I didn't even know these could occur in JavaScript. The problem seems to be related to the purging of the publisher cache. The situation I experience the error in is fairly complex (with multiple listeners subscribing, unsubscribing and signaling, elements being replaced and the like. I haven't yet been able to reproduce the issue with a simpler use case and I'm not entirely sure what exactly happens here. Maybe someone with a better understanding of JavaScript could help here? What seems to happen is that one thread (for want of a better word) calls the createPublisher function. Shortly afterward, another thread calls the subscribe function on the same topic, leading to the cache for that topic being cleared.
Now when the first "thread" arrives in line 167, where it says

for (var i = 0; i < publisher.listeners.length; i++) {

publisher.listeners is undefined as the reference was deleted in between.
I managed to fix the issues I encounter by creating a clone of the publisher.listeners array and using that for the loop. I would have created a JIRA but I'm quite at a loss as to explaining what exactly is going on here.

Regards,
Jochen



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to