Do not start background activities

A function invocation finishes once termination is signaled. Any code run after graceful termination cannot access the CPU, and will not make any progress. In addition, when a subsequent invocation is executed in the same environment, your background activity resumes, interfering with the new invocation. This may lead to unexpected behavior and errors that are hard to diagnose. Accessing the network after a function finishes usually leads to connections being reset (and the ECONNRESET error code).

Background activity is anything that happens after your function has terminated. It can often be detected in logs from individual invocations by finding anything that is logged after the line saying that the invocation ...

Get DevOps for Serverless Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.