0

We are trying to add an edge between two vertex using nodejs running in Lambda and aws neptune. We can easily add a vertex, but when we try to add an edge, our Lambda timesout. Our timeout is set to 20 seconds.

Here is the code.

async function updateDoc (db, dataTmp, now, id, callback, logData, errorData) {
  try {
    console.log('inside updateDoc function')   

    console.log(dataTmp)        

    var user1 = await g.V().hasLabel('user').has('userId', dataTmp.userId).valueMap().unfold().toList()
console.log('user1', user1)
var user2 = await g.V().hasLabel('user').has('userId', dataTmp.trustedUserId).valueMap().unfold().toList()
console.log('user2', user2)
const edgeAdded =  await g.V().hasLabel('user').has('userId', dataTmp.userId).as('u').V().hasLabel('user').has('userId', dataTmp.trustedUserId).as('tu').addE('trust').from('u').to('tu').next()
console.log('edgeAdded making asynch', edgeAdded)
    // dc.close()        
    return callback(null)
  } catch (error) {
    return callback(null)
  }    

}

Here is the output from lambda

{8 items "type":"AddTrustedUser"

"userId":"5ed1cd97ee7ac30008b86a8c"

"trustedUserId":"5ed1cd98ee7ac30008b86a8d"

"dupId":"r54sw17ND"

"time":"2020-05-30T03:06:02.632Z"

"initTime":"2020-05-30T03:06:02.632Z"

"lastTime":"2020-05-30T03:06:02.632Z"

"logsGroupName":"AddTrustedUser" }

user1 [

Map { 'firstName' => [ 'jaat' ] },

Map { 'userId' => [ '5ed1cd97ee7ac30008b86a8c' ] }

]

user2 [

Map { 'firstName' => [ 'maat' ] },

Map { 'userId' => [ '5ed1cd98ee7ac30008b86a8d' ] }

]

REPORT Duration: 20020.15 ms Billed Duration: 20000 ms Memory Size: 1024 MB Max Memory Used: 103 MB Init Duration: 745.55 ms [+20021ms] 3 minutes ago cafbd19c-7b7a-4acb-b3fb-134bb51f054f Task timed out after 20.02 seconds [+20021ms]

Any pointers on what we are doing wrong.

pkpk
  • 641
  • 1
  • 7
  • 18
  • I don't see a `terminal` step at the end of the query such as `iterate()` or `toList()` also given it is an async function would you not want to `await` the query? – Kelvin Lawrence May 29 '20 at 19:49
  • Thanks Kelvin for a quick response. We will try with await and next and update here. Thanks for writing the book, its a great reference. – pkpk May 29 '20 at 22:41
  • We are still seeing timeouts during addE query – pkpk May 30 '20 at 11:27
  • When adding the edge rather than end the traversal with `next()` have you tried `iterate()` or `toList()` ? – Kelvin Lawrence Jun 03 '20 at 15:33
  • I have not tried iterate() or toList(), but changing from() to from_() fixed the issue. http://tinkerpop.apache.org/docs/current/reference/#from-step . I was thinking only python needs from_, it seems nodejs needs it as well. – pkpk Jun 05 '20 at 03:27

1 Answers1

0

Changing from() to from_() fixed the issue. tinkerpop.apache.org/docs/current/reference/#from-step

pkpk
  • 641
  • 1
  • 7
  • 18