Navigation

    APPDRAG Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular

    REMINDER

    Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

    SOLVED Scheduled Function not running....?

    Cloud Backend (Cloud DB, API Builder)
    3
    6
    635
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Daniel Mulroy
      Daniel Mulroy last edited by

      Hello team,

      The scheduled function FUNCTION_161968 of my project goodvibes-474a9a works perfectly when I run it with "Try", but only works intermittently as a scheduled function. I can't seem to understand/predict when / how / why it works sometimes or not.

      It's something I need to run reliably every day at 1 AM. @App-Drag @Joseph-Benguira can someone help me understand why it might not be working?

      J 1 Reply Last reply Reply Quote 0
      • J
        jbenguira @Daniel Mulroy last edited by

        @daniel-mulroy please check the detected time zone. Also try to schedule it 1h later. Because of timezone calculation it could end up being scheduled at gmt+0 00:00 and so never been triggered, or even change it to be runned at non zero minute (01:03 for eg)

        1 Reply Last reply Reply Quote 0
        • Daniel Mulroy
          Daniel Mulroy last edited by

          Interesting. I have changed it to run at 2:05 AM, but here was the previous configuration, FYI. We will see if it starts working again 🙂 Thanks!

          Screen Shot 2022-02-17 at 3.06.59 PM.png

          1 Reply Last reply Reply Quote 0
          • Daniel Mulroy
            Daniel Mulroy last edited by

            @jbenguira Sorry to report, I have removed "Require API Key" and set the recurrence to every 5 minutes, it is still not working.

            Screen Shot 2022-03-03 at 8.24.31 PM.png

            It says there are 172 executions today, which means it is probably running every 5 minutes... but the result of the function is not happening.

            Is there any difference in the execution environment between clicking "try" and running via Scheduler?

            Joseph Benguira 1 Reply Last reply Reply Quote 0
            • Joseph Benguira
              Joseph Benguira @Daniel Mulroy last edited by Joseph Benguira

              @daniel-mulroy so the execution count indicate that the function is indeed executed
              I don't know what you are doing in the function, but I guess it could be a difference based on ENV vars or global vars?

              Daniel Mulroy 1 Reply Last reply Reply Quote 0
              • Daniel Mulroy
                Daniel Mulroy @Joseph Benguira last edited by

                @joseph-benguira

                Solved... and I think I know why, very edge case 🙂

                I had a callback at the very end of my function handler, after a bunch of async/await stuff.

                Lambda has a context object:
                "callbackWaitsForEmptyEventLoop"

                From their docs:
                "Set to false to send the response right away when the callback runs, instead of waiting for the Node.js event loop to be empty. If this is false, any outstanding events continue to run during the next invocation."

                Anyway, removing the callback at the end of the function worked. I think lambda was executing the callback without waiting for the inner await'd functions to finish, which killed the running processes and prevented the updates from happening.

                Does "Try" run with a different context object than a scheduled function?

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post