I'm using googleapis (NodeJS) with AWS lambda functions that create calendar invitations on behalf of users.
- Get the available timeslots using google.calendar.freebusy.query()
- Creates the invitation using google.calendar.events.insert()
Step 1 works just fine. But recently, step 2 started throwing this error:
FetchError: request to https://www.googleapis.com/calendar/v3/calendars/primary/events?sendUpdates=all failed, reason: socket hang up
The error happens only when deployed to AWS. It works fine locally using serverless-offline. Also, if I try 10 times, about 1 - 2 of them create the invitation and the rest fails. When it fails, it takes about 5-8 minutes to display the error.
Any guide on this would be much appreciated.
Server env:
- Node v14.17.2
- googleapis 95.0.0 (Tried downgrading to 89, 76 & 59 and that doesn't work)
- serverless v1.83.3
Creating invitations:
await googleCalendar.events.insert(
{
sendUpdates: "all",
calendarId: "primary",
resource: newEvent,
},
(err, res) => {
if (err) {
console.log('Failed to send the invitation', error)
// this is where I'm catching the above error
}
}
);