Timeout when query can't find matching documents

CB version 7.0
Node SDK version 3.2.0

When running an N1QL query with the node SDK I get a timeout when the query doesn’t find a matching document. If I run the same query in the web GUI it returns an empty array as expected. If I change the query so that it find a document it also works. The same query used to work in CB 7.0-beta and SDK 3.2.0-beta but stopped working after I updated it. Any idea what might be causing this?

Some example code (although I don’t believe this will mean much since it seem to happen to all queries):

let cluser = await couchbase.Cluster.connect(...);
let bucket = cluster.bucket(...);
let scope = bucket.scope(...);
let query = "SELECT META(`users`).id, email, firstName, lastName FROM `users` WHERE tenantId = '<Some ID>' AND email = 'does-not-exist@example.com'" // <-- If I change this to example@example.com it doesn't time out since it find a document

let result = await db.scope.query(query, {readOnly: true}); // <--- timout

And the users collection:

  "email": "example@example.com",
  "firstName": "My",
  "lastName": "Name",
  "tenantId": "<Some ID>", // <-- Indexed

After some troubleshooting it seems the cause of this is passing readOnly: true to the query. If set to false the query works as expected. I’ve replicated the issue in a clean repo here: GitHub - traed/couchbase-test

Thanks @traed , I have created a ticket on our side to track this issue.

Thanks for the Github repo.

Hey @traed ,

I think I’ve managed to reproduce this issue and hoping to have a fix available for the next release.

Cheers, Brett

Thanks @AV25242 and @brett19 . We can of course work around this issue by just omitting the read only flag. However, I just encountered another similar issue. When upserting binary files during an import we need to specify the option durabilityLevel: 2 in order to not risk running out of memory. This used to work fine but now we get an error like this:

[Error: LCB_ERR_KVENGINE_INVALID_PACKET (1031): A badly formatted packet was sent to the server. Please report this in a bug] {
    code: 1031,
    ctxtype: 'kv',
    status_code: 4,
    opaque: 107,
    cas: CbCas { '0': <Buffer 00 00 00 00 00 00 00 00> },
    key: '<document key>',
    bucket: '<bucket name>',
    collection: '<collection name>',
    scope: '<scope name>',
    context: 'Invalid encoding in FrameExtras',
    ref: ''

Removing the options object from the call to upsert (and in this case importing a smaller batch of files) works, which makes me think there is a larger problem with these query options. It’s rather concerning that all these issues arise when updating to 7.0 when they worked fine in the beta…