Set a custom timeout inside a query?

Hi Everyone!
I am looking to specify a max timeout for a simple query using an index and using the node-sdk.
I saw in the go-sdk docs (Client Settings | Couchbase Docs)

Name: QueryTimeout

Default: 75s

The Query timeout is used on all N1QL query operations if not overridden by a custom timeout. Note that it is set to such a high timeout compared to key/value since it can affect hundreds or thousands of rows.

Does anyone know how to set a custom timeout within a query in node?

Heh @brett19 I have the same question.

Is there a way to submit a query via the node sdk with custom query specific timeout?

You can set a global query timeout in connect options ConnectOptions | couchbase

await couchbase.connect('couchbase://localhost', {
    username: 'Administrator',
    password: 'password',
    queryTimeout: 75000
})

You can set a per operation query timeout in query options QueryOptions | couchbase

const query = `
  SELECT airportname, city FROM \`travel-sample\`.inventory.airport
  WHERE city=$1
  `;
const options = { parameters: ['San Jose'], timeout: 75000 }
let result = await cluster.query(query, options)

Hope that helps

1 Like

@jrawsthorne
Thanks!
A little more work than I was hoping for but I think this will do it!