Firebase Cloud Function called twice onCreate

Viewed 787

I have this function:

'use strict';

const functions = require('firebase-functions');
const admin = require('firebase-admin');

exports.myFunction = functions.database.ref('/my_node/{myId}/status').onCreate(event => {
  const data = event.data.val();
  if (data == 'STATE01') {
    return event.data.ref.set('STATE02');
  }
});

I am using onCreate, it should be called once only. But it has called 2 times

9:29:27.975 PM myFunction Function execution took 33 ms, finished with status: 'ok'

9:29:27.943 PM myFunction Function execution started

9:29:27.875 PM myFunction Function execution took 1059 ms, finished with status: 'ok'

9:29:26.818 PM myFunction Function execution started

0 Answers
Related