yfinkelstein/node-zookeeper — pull request #40 by silas (2012-03-12 20:43:49+00:00)
Title: Fix issue where on reconnect events lost hidden values

When an connection fails to a server and certain watches are active a failure occurs and kills the node process.

1. Download latest ZooKeeper server
2. Start using the following command

./bin/zkServer.sh start

3. Create test value

./bin/zkCli.sh create /test bla

4. Install latest version of node-zookeeper

npm install git://github.com/yfinkelstein/node-zookeeper.git

5. Create the following `test.js` script

var ZooKeeper = require('zookeeper')

var client = new ZooKeeper({
connect: 'localhost:2181',
timeout: 200000,
debug_level: ZooKeeper.ZOO_LOG_LEVEL_DEBUG,
host_order_deterministic: false
})

client.connect(function(err) {
if (err) throw err

var watch = function() {
client.aw_get('/test', function() {
console.log('===============================================================')
console.log('= watch')
console.log('===============================================================')
console.log(arguments)
watch()
},
function() {
console.log('===============================================================')
console.log('= data')
console.log('===============================================================')
console.log(arguments)
})
}
watch()
})

6. Run the node script

node test.js

7. Restart ZooKeeper server

./bin/zkServer.sh restart

When I do this I get an `Aborted (core dumped)` error.

From what I can tell when the ZooKeeper client reconnects it fires the events again and because the the zk property and callback references have be removed, an error occurs.

I'm not sure if just not removing the references is the right answer, but it seems to have already been done in the CALLBACK_PROLOG macro.