Execution after HTTP response

Example of code that won't execute after an HTTP response is sent.

Code sample


To authenticate to Cloud Functions, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

const functions = require('@google-cloud/functions-framework');

 * HTTP Cloud Function that may not completely
 * execute due to early HTTP response
 * @param {Object} req Cloud Function request context.
 * @param {Object} res Cloud Function response context.
functions.http('afterResponse', (req, res) => {

  // This statement may not execute
  console.log('Function complete!');

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.