Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Intermittent SyntaxError on cloud function

Seeing below errors intermittently:

SyntaxError: Unexpected token e in JSON at position 713 at JSON.parse (<anonymous>) at parse (/layers/google.nodejs.functions-framework/functions-framework/node_modules/body-parser/lib/types/json.js:89:19)

 

Purpose of Cloud function: read request and send it to logs (Logging) 

Issue: Intermittent syntax error, sometimes error comes after function is done logging (towards end). Sometimes its at start. Tracing request ID, no issue was found with request.  Rerun of request did not result in issue replication.

 

Seems like node js is stuck or having some issues with instances 

Solved Solved
0 2 1,138
1 ACCEPTED SOLUTION

We got service ticket opened and got it resolved. It was due to race condition as async (log.write) function was being called without await on it.

View solution in original post

2 REPLIES 2

Can you include more details about the Cloud Function you have deployed such as region and dependencies? Can you also share a request sample that has failed being parsed in your function? On the other hand, have you continued experiencing these intermittent errors in your Function?

We got service ticket opened and got it resolved. It was due to race condition as async (log.write) function was being called without await on it.