Strange problem with N1QL query

I have some code in Node JS which calls a N1QL query to get all tasks for a user which looks like this

 qContactTasks: `SELECT meta().id as DocId, d.body,status, startDateTime,dueDateTime, method,referenceId
FROM Contacts as d
where _type = 'followup' and referenceId = $1
order by startDateTime`

The code which calls makes the actual DB call looks like this

const n1qlQuery_wId = (bucket, N1qlQuery,n1qlStr, id)=>{
  return new Promise((resolve,reject)=>{
      query = N1qlQuery.fromString(n1qlStr)
      console.log("Key Passed; " + id)
      bucket.query(query, [id], (err, result, meta)=>{
      if(err) return reject(err);
                return resolve([result, meta])             

and this is how i call it

let tasks = await cb.n1qlQuery_wId(req.bucket,req.N1qlQuery, cbQ.qContactTasks, myNewKey )

now here is the wired part, if i use a myNewKey which was set like this var myNewKey = newContact._type + “::” + newContact._id and has a value like contact::9539d3b6-cd85-4885-ab73-09cfe861a50f it does not work and i get 0 records back for my query… if i call my query like this
let tasks = await cb.n1qlQuery_wId(req.bucket,req.N1qlQuery, cbQ.qContactTasks, "contact::9539d3b6-cd85-4885-ab73-09cfe861a50" )
i get the 2 records back as expected. I can see that in both cases i am passing the same keys

here is my console log

DocId : contact::9539d3b6-cd85-4885-ab73-09cfe861a50f
Task Result: {“docID”:“followup::14a08ec3-b889-4855-9888-c213beb62dfd”,“result”:{“cas”:“1553708447696355328”}}
Task Result: {“docID”:“followup::bc1727c1-adec-4500-8afe-ea31516922e5”,“result”:{“cas”:“1553708447696551936”}}
Key Passed; contact::9539d3b6-cd85-4885-ab73-09cfe861a50f
[ ,
{ requestID: ‘6edfdcd1-1b8c-4317-8d84-2a7be614a6fe’,
{ DocId: ‘json’,
body: ‘json’,
dueDateTime: ‘json’,
method: ‘json’,
referenceId: ‘json’,
startDateTime: ‘json’,
status: ‘json’ },
status: ‘success’,
{ elapsedTime: ‘20.37093ms’,
executionTime: ‘20.102492ms’,
resultCount: 0,
resultSize: 0 } } ]

what could cause this behavior and is there anyway to troubleshoot this ?

As this drove me nuts i think i nailed this down less to the string then a delay. It seems if i go and insert some docs and then want to query them right after insert the N1QL query will not find them. Is there a rule how long one has to wait before these will be avail for query ? Right now i put a sleep of 500 ms in and i get the data as expected but how does one handle this normally ?

May be you want to consider scan consistency