Search code examples
node.jsaws-lambdagremlinamazon-neptune

Lambda timeout when adding an edge using nodejs to aws neptune using gremlin


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.


Solution

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