title: "Callback function is not a function" Error when following Google Cloud Scheduler / PubSub tutorial
body: <p>I am trying to create to a start/stop schedule for my VM instance on Google Cloud. I am following this <a href="https://cloud.google.com/scheduler/docs/start-and-stop-compute-engine-instances-on-a-schedule" rel="nofollow noreferrer">tutorial</a>created by Google but when I get to the <strong>(Optional) Verify the functions work</strong> section and try to test the <em>stopInstancePubSub</em> function and pass the <em>{"data":"eyJ6b25lIjoidXMtd2VzdDEtYiIsICJsYWJlbCI6ImVudj1kZXYifQo="}</em> JSON object I get the following error:</p>
  
  <pre><code>2019-06-09 17:23:54.225 EDT
  stopInstancePubSub
  ipmdukx38xpw
  TypeError: callback is not a function at exports.stopInstancePubSub (/srv/index.js:55:5) at /worker/worker.js:825:24 at &lt;anonymous&gt; at process._tickDomainCallback (internal/process/next_tick.js:229:7)
  </code></pre>
  
  <p>Not sure what I am doing wrong here, am I missing another argument to pass to the function?</p>
  
  <p>*Edit: The code being used is taken from Googles Tutorial:</p>
  
  <pre><code>const Buffer = require('safe-buffer').Buffer;
  const Compute = require('@google-cloud/compute');
  const compute = new Compute();
  
  /**
   * Stops a Compute Engine instance.
   *
   * Expects a PubSub message with JSON-formatted event data containing the
   * following attributes:
   *  zone - the GCP zone the instances are located in.
   *  instance - the name of a single instance.
   *  label - the label of instances to start.
   *
   * Exactly one of instance or label must be specified.
   *
   * @param {!object} event Cloud Function PubSub message event.
   * @param {!object} callback Cloud Function PubSub callback indicating completion.
   */
  exports.stopInstancePubSub = (event, callback) =&gt; {
    try {
      const pubsubMessage = event.data;
      const payload = _validatePayload(
        JSON.parse(Buffer.from(pubsubMessage.data, 'base64').toString())
      );
      const options = {filter: `labels.${payload.label}`};
      compute.getVMs(options).then(vms =&gt; {
        vms[0].forEach(instance =&gt; {
          if (payload.zone === instance.zone.id) {
            compute
              .zone(payload.zone)
              .vm(instance.name)
              .stop()
              .then(data =&gt; {
                // Operation pending.
                const operation = data[0];
                return operation.promise();
              })
              .then(() =&gt; {
                // Operation complete. Instance successfully stopped.
                const message = 'Successfully stopped instance ' + instance.name;
                console.log(message);
                callback(null, message);
              })
              .catch(err =&gt; {
                console.log(err);
                callback(err);
              });
          }
        });
      });
    } catch (err) {
      console.log(err);
      callback(err);
    }
  };
  
  /**
   * Validates that a request payload contains the expected fields.
   *
   * @param {!object} payload the request payload to validate.
   * @return {!object} the payload object.
   */
  function _validatePayload(payload) {
    if (!payload.zone) {
      throw new Error(`Attribute 'zone' missing from payload`);
    } else if (!payload.label) {
      throw new Error(`Attribute 'label' missing from payload`);
    }
    return payload;
  }
  </code></pre>