Can not deploy async function to Google Cloud Functions

google cloud functions async/await
google cloud functions node version
cloud function deploy nodejs
google cloud functions middleware
google cloud function with node js
google cloud functions node js 8
google cloud functions node 8 version
google cloud functions dependencies

I am using the newest version of Node, v8.9.1, but I get this error when deploying the code below:

Function load error: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/index.js:550
  async function deleteQueryBatch(db, query, batchSize, results) {

SyntaxError: Unexpected token function

Code (dummy function is needed to get the error):

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const db = admin.firestore()

exports.some = functions.firestore.document('x/{x}').onCreate(event => {


function deleteCollectionAndReturnDeletedDocs(db, collectionRef, batchSize) {
    return deleteQueryBatch(db, collectionRef.limit(batchSize), batchSize, []);
  async function deleteQueryBatch(db, query, batchSize, results) {
    const snapshot = await query.get();
    if (snapshot.size > 0) {
      let batch = db.batch(); => {
        if (doc.exists) {

      await batch.commit();
    if (snapshot.size >= batchSize) {
      return deleteQueryBatch(db, query, batchSize, results);
    } else {

      return results;

How can I deploy the async function? I do not get this error on a server on Evennode.

Cloud Functions currently runs Node 6 LTS, which means it doesn't support async/await natively. If you want to use some form of async/await, you'll have to transpile your ES7 or TypeScript into ES6 so it can run in the Node container provided by Cloud Functions. The transpiler should convert async/await into equivalent code using promises.

The team is looking into also providing Node 8 LTS.

The Node.js 8 Runtime | Cloud Functions Documentation, Functions don't deploy and throw "@google-cloud/storage" error #1222 Error message: Code in file lib/index.js can't be loaded. async function request(opts) { ^^^^^^^^ SyntaxError: Unexpected token function at .com/questions/​55866695/read-document-in-firestore-from-firebase-oncall-cloud-function  Cloud Firestore is used to store the state of jobs. Follow the server quickstart documentation to create a Cloud Firestore database. Deploy Cloud Functions gcloud functions deploy Jobs --runtime go111 --trigger-http Create jobs and check their state. After the function is deployed, we can use POST and GET methods to interact with long-running

As NodeJS 8.x is LTS now, it should work, right?

When I type "node --version" into my Google Cloud console, it shows me 8.5.0 as version of node.

But when I deploy a script via "gcloud beta functions deploy", I get a "SyntaxError: Unexpected identifier" at the position of my script where the first "await" is used.

So is async/await disabled in the Google Cloud?

Tips & Tricks | Cloud Functions Documentation, Cant deploy my functions to Firebase #20666 According to Google Cloud Function docs - the latest supported LTS version for Node.js is 6. Deployment. Deployments work by uploading an archive containing your function's source code to a Google Cloud Storage bucket. You can deploy Cloud Functions from your local machine, from your GitHub or Bitbucket source repository (via Cloud Source Repositories), or from the Cloud Functions API directly.

I got this error when deploying my async functions through the Google Cloud Platform. Even though I was running a newer NodeJS version locally I deployed as v6. You can deploy your function as NodeJS v6 or v8. As of January 2019, v6 was the default selection and requires selecting v8(Beta) before deployment.

Functions don't deploy and throw "@google-cloud/storage" error , You Can Now Write Google Cloud Functions with Node.js 8 by deploying a function that uses a couple of features that weren't Let's try out the Node.js 8 runtime with a simple HTTP function that uses async , await and the  Deploying from Your Local Machine This page shows you how to deploy a Cloud Function from your local machine using the gcloud command-line tool. When using the command-line tool, Cloud Functions packages and uploads the contents of your function's directory to a Cloud Storage bucket for you and automatically excludes unnecessary files via the .gcloudignore file.

Async keeps giving me an error. Cant deploy my functions to , Your browser does not currently recognize any of the video formats available. After you write and deploy a function, Google's servers begin to manage the  Do more for less with Google Cloud; Our customer-friendly pricing means more overall value to your business.

You Can Now Write Google Cloud Functions with Node.js 8, TypeScript supports latest JavaScript features like async/await, simplifying is transpiled every time you deploy your code to Cloud Functions for Firebase. the existing package.json file, select No unless you are sure you don't want to keep  Also note that when you deploy a function for the first time, you must include the --runtime flag. The --runtime flag is not required on subsequent deployments of the function. The command uses the following arguments to gcloud functions deploy:

Cloud Functions for Firebase, Google Cloud Functions is a lightweight, event-based, asynchronous compute Cloud Function are modules written in Javascript and run in a Node runtime. post, you can deploy configuration files/credential keys for access (not advised to​  By terminating functions correctly, you can avoid excessive charges from functions that run for too long or loop infinitely. Also, you can make sure that the Cloud Functions instance running your function does not shut down before your function successfully reaches its terminating condition or state.

  • No you see your own local node version, not googl’d version. See Doug’s link, it is still 6.x.
  • Ahm... when I'm on and THERE (on the website!) enter the cloud console, it's technical impossible that this accesses my local console / node installation and gives me my local node version. Also, my local node version is 8.9.1 and not 8.5.0 as printed out in the cloud console. So version 8.5.0 comes definitely from the google cloud.