Node.js View Query Crashes Silently

Calling vew.query() crashes node.js process without error. The CB admin console stats show that the requests are being made, but the process exits before the callback function is called.

        try  {
            var view = cb.view("designDoc", "viewName", null);
            view.query(null, function (err, viewResults) {
 
            });
        } catch (err) {
            console.log(err);
        }

I'm using Windows 7 / libcouchbase v2.1.3 / couchnode v1.0.0.

Is anyone else having this issue?

Update:
After building couchnode with debug info, I now get an assertion failure (see comment below) when calling a view. The call stack can be seen below

 	couchbase_impl.node!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1328	C++
 	couchbase_impl.node!_free_dbg(void * pUserData, int nBlockUse) Line 1265	C++
 	couchbase_impl.node!free(void * pUserData) Line 50	C++
>	couchbase_impl.node!free_bufinfo_common(lcb_buf_info * bi) Line 186	C
 	couchbase_impl.node!release_writebuf(lcb_io_opt_st * iobase, lcb_sockdata_st * sd, lcb_io_writebuf_st * buf) Line 412	C
 	libcouchbase.dll!000007feee4d1b4d()	Unknown
 	couchbase_impl.node!write_callback(uv_write_s * req, int status) Line 436	C

The failed assert is checking CrtIsValidHeapPointer (windows function), and the pointer being passed to this is lcb_buf_info->ringbuffer (see plugin-libuv.c line 186). lcb_buf_info->root contains the request headers for the view request being made. The entire lcb_buf_info can be seen below:

-		bi	0x000000000370aa68 {root=0x0000000000397f10 "GET /default/_design/SimUsers/_view/licenses_owned?limit=5 HTTP/1.1\r\nUser-Agent: libcouchbase/2.1.3\r\nConnection: close\r\nAccept: application/json\r\nHost: couchbase.winmachine:8092\r\n\r\n" ...}	lcb_buf_info *
+		root	0x0000000000397f10 "GET /default/_design/SimUsers/_view/licenses_owned?limit=5 HTTP/1.1\r\nUser-Agent: libcouchbase/2.1.3\r\nConnection: close\r\nAccept: application/json\r\nHost: couchbase.winmachine:8092\r\n\r\n"	char *
		size	0	unsigned __int64
		ringbuffer	0x000000000032b2d0 {...}	ringbuffer_st *
-		iov	0x000000000370aa80 {{iov_base=0x0000000000397f10 "GET /default/_design/SimUsers/_view/licenses_owned?limit=5 HTTP/1.1\r\nUser-Agent: libcouchbase/2.1.3\r\nConnection: close\r\nAccept: application/json\r\nHost: couchbase.winmachine:8092\r\n\r\n" ...}, ...}	lcb_iovec_st[2]
+		[0]	{iov_base=0x0000000000397f10 "GET /default/_design/SimUsers/_view/licenses_owned?limit=5 HTTP/1.1\r\nUser-Agent: libcouchbase/2.1.3\r\nConnection: close\r\nAccept: application/json\r\nHost: couchbase.winmachine:8092\r\n\r\n" ...}	lcb_iovec_st
+		[1]	{iov_base=0x0000000000397f10 "GET /default/_design/SimUsers/_view/licenses_owned?limit=5 HTTP/1.1\r\nUser-Agent: libcouchbase/2.1.3\r\nConnection: close\r\nAccept: application/json\r\nHost: couchbase.winmachine:8092\r\n\r\n" ...}	lcb_iovec_st

I'm starting to think that this may be a libcouchbase_2.1.3 issue and not a couchnode issue, but I'm not sure at this point. Maybe Brett or someone else on the couchnode team can better determine where the issue lies.

1 Answer

« Back to question.

Unfortunately I am unable to reproduce this issue. I am using Windows 7 x64 with Visual Studio 2012. Node.js version v0.10.18. libcouchbase x64 2.1.3 downloaded from couchbase.com and placed in C:\couchbase. Couchnode 1.0.0 built from npm. For me, your example code above executes flawlessly (though I do have to swap out ‘designDoc’ and ‘viewName’ with views that I have available). Would you be able to provide any more details on the dataset that you are using as well as your view code? It may also be helpful to know what your build environment looks like.

Cheers, Brett