I have created a Netlify Function (Lambda) which creates new document in database. It works on localhost (using netlify dev), but I receive a “network timeout” error after code is uploaded to Netlify:
5:32:27 PM: 2020-12-29T16:32:27.124Z 6b6b680d-ca66-4cdc-9cd1-a9289849ef46 ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"FetchError: network timeout at: https://db.fauna.com/","reason":{"errorType":"FetchError","errorMessage":"network timeout at: https://db.fauna.com/","message":"network timeout at: https://db.fauna.com/","type":"request-timeout","stack":["FetchError: network timeout at: https://db.fauna.com/"," at Timeout.<anonymous> (/var/task/src/node_modules/node-fetch/lib/index.js:1454:13)"," at listOnTimeout (internal/timers.js:554:17)"," at processTimers (internal/timers.js:497:7)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: FetchError: network timeout at: https://db.fauna.com/"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:314:20)"," at processPromiseRejections (internal/process/promises.js:209:33)"," at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
5:32:27 PM: [ERROR] [1609259547134] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 403.
5:32:27 PM: Duration: 20.30 ms Memory Usage: 76 MB
5:32:27 PM: RequestId: 6b6b680d-ca66-4cdc-9cd1-a9289849ef46 Error: Runtime exited with error: exit status 128
Runtime.ExitError
Function code:
// Create new user profile in Fauna database
var faunadb = require('faunadb'),
q = faunadb.query
exports.handler = async function(event, context) {
var client = new faunadb.Client({ secret: process.env.FAUNADB_SECRET })
const email = event.queryStringParameters.email
const name = event.queryStringParameters.name
const accountName = event.queryStringParameters.accountName
const accountId = event.queryStringParameters.accountId
const propertyName = event.queryStringParameters.propertyName
const propertyId = event.queryStringParameters.propertyId
const propertyTimezone = event.queryStringParameters.propertyTimezone
const dataset = event.queryStringParameters.dataset
var createP = client.query(
q.Create(
q.Collection('users'),
{ data: {
email: email,
name: name,
account: {
name: accountName,
id: accountId,
},
property: {
name: propertyName,
id: propertyId,
timezone: propertyTimezone,
},
dataset: dataset,
}
}
)
)
return {
statusCode: 200,
body: ""
};
}
Any ideas what might be wrong here?