[TypeError: Cannot read property 'status' of undefined] at ret (/opt/shop/node_modules/couchbase/lib/http.js:15:26)

2013-09-28

Environment
node version: 0.10.18
couchbase server version: 2.1.1 community
couchbase client C version: 2.1.3
couchbase client node version: latest from git (til 2013-09-28)
OS: amazon version linux
Setting: 2 nodejs (medium) connect to 1 couchbase servers (large). a load balancer will distribute the requests to these 2 nodejs server

When I use another machine to do apache benchmark test, it keeps giving this error after finishing around 2500 requests. the apache benchmark will send numbers of requests to nodejs and each request is a batch of 6 view queries. When nodejs receives the batch, it will deserialize the batch into 6 simple view queries and then reflect them to load balancer. Then nodejs will ask the couchbase for the view data at that moment.

When I change to use 1 nodejs, it wont show the error. It seems too many connections will break

ab command: ab -p ~/post.txt -T application/json -e ~/percentage.txt -c 60 -t 60

/opt/shop/node_modules/couchbase/lib/http.js:15 if (error && response.status < 200 || response.status > 299) { ^ TypeError: Cannot read property 'status' of undefined at ret (/opt/shop/node_modules/couchbase/lib/http.js:15:26)

[2013-09-28 05:40:50.969] [ERROR] /run.js - { [TypeError: Cannot read property ‘status’ of undefined]
domain:
{ domain: null,
_events: { error: [Function] },
_maxListeners: 10,
members: [] },
domainThrown: true }
TypeError: Cannot read property ‘status’ of undefined
at ret (/opt/shop/node_modules/couchbase/lib/http.js:15:26)
at ViewQuery._request (/opt/shop/node_modules/couchbase/lib/viewQuery.js:157:12)
at ViewQuery.query (/opt/shop/node_modules/couchbase/lib/viewQuery.js:84:8)
at app.get.params.key (/opt/shop/js/products.js:74:74)
at callbacks (/opt/shop/node_modules/express/lib/router/index.js:164:37)
at param (/opt/shop/node_modules/express/lib/router/index.js:138:11)
at param (/opt/shop/node_modules/express/lib/router/index.js:135:11)
at param (/opt/shop/node_modules/express/lib/router/index.js:135:11)
at param (/opt/shop/node_modules/express/lib/router/index.js:135:11)
at pass (/opt/shop/node_modules/express/lib/router/index.js:145:5)

==================================================================
2013-09-29

I changed your code to be this

/if (error && response.status < 200 || response.status > 299) {
error = new Error("HTTP error " + response.status);
}
/
if (error) {
return innerCallback(error, null);
}

try {
body = JSON.parse(response.data);
} catch (parseError) {
// Error talking to server, pass the error on for now
return innerCallback(parseError, null);
}

I got this error

[2013-09-29 06:27:35.245] [ERROR] /js/products.js - { [Error: Connection failure] code: 24 } Error: Connection failure at ViewQuery._request (/opt/shop/node_modules/couchbase/lib/viewQuery.js:157:12) at ViewQuery.query (/opt/shop/node_modules/couchbase/lib/viewQuery.js:84:8) at app.get.params.key (/opt/shop/js/products.js:74:74) at callbacks (/opt/shop/node_modules/express/lib/router/index.js:164:37) at param (/opt/shop/node_modules/express/lib/router/index.js:138:11) at param (/opt/shop/node_modules/express/lib/router/index.js:135:11) at param (/opt/shop/node_modules/express/lib/router/index.js:135:11) at param (/opt/shop/node_modules/express/lib/router/index.js:135:11) at pass (/opt/shop/node_modules/express/lib/router/index.js:145:5) at nextRoute (/opt/shop/node_modules/express/lib/router/index.js:100:7) at callbacks (/opt/shop/node_modules/express/lib/router/index.js:167:11)

I have some conclusions and questions

  1. I think this line is not enough to handle the error

    if (error && response.status < 200 || response.status > 299)
  2. if error occurs, it keeps proceeding to the next line and returns another error. Therefore it should directly
    return innerCallback(error, null);

    once an error ocurrs
  3. Does anybody know why the connection was failed at the middle stage not at the beginning stage?