Fix loop() blocks cloud function issue.