Skip to content

Long running Cloud Functions are self-executing #4091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
justingosan opened this issue Aug 10, 2017 · 6 comments
Closed

Long running Cloud Functions are self-executing #4091

justingosan opened this issue Aug 10, 2017 · 6 comments

Comments

@justingosan
Copy link

Issue Description

Long running Cloud Functions are self-executing.

Steps to reproduce

Have a really long running Cloud Function

Parse.Cloud.define('longRunningFn', (req, res) => {
     console.log('executing...');
     setTimeout(res.success, 1000000);
});

and execute it once Parse.Cloud.run('longRunningFn');

Expected Results

Should only run once (1 log line)

executing...

Actual Outcome

After a while of running, it will execute again... and again.. and again..

executing...
executing...
executing...
executing...

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.3.7
    • Operating System: macOS
    • Hardware: Macbook Pro 2017
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Local
  • Database

    • MongoDB version: 3.4.6
    • Storage engine: MongoDB
    • Hardware: Macbook Pro 2017
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Local

Logs/Trace

Include all relevant logs. You can turn on additional logging by configuring VERBOSE=1 in your environment.

@natanrolnik
Copy link
Contributor

natanrolnik commented Aug 10, 2017

Who is calling this function? If it's from the SDKs, then probably it reached the timeout and retried for a few times. If that's the case, you should configure the number of retries to 0.

@natanrolnik
Copy link
Contributor

Check this issue here: #3651
Also, if you have a function than runs for so long, you should rethink it.

@justingosan
Copy link
Author

Thanks for the heads up. I'm using the Javascript SDK but I can't seem to find the option to set retries. http://docs.parseplatform.org/js/guide/#getting-started

Mind if you point me to the right direction? :)

@addisonElliott
Copy link
Contributor

I don't think you can set the timeout in the Javascript SDK (as with most of the other Parse SDKs).

I haven't worked with Javascript in great detail, but let me show you some indication why I think this. The following file is where REST commands are sent. This occurs in the function ajax and ajaxIE9. ajax uses XHttpRequest and ajaxIE9 uses XDomainRequest.

https://github.com/parse-community/Parse-SDK-JS/blob/73ccdd3ce5031db81eaed1ffd8523c08efb74b5c/src/RESTController.js

In either case, there are timeout variables for each type that can be set but are not and there are no options to.

The one odd thing that I cannot figure out is that the timeout is supposed to be infinite if not set, which is not the case for you.

@flovilmart
Copy link
Contributor

@justingosan you should not have long running functions otherwise you'll hit the timeout, you should return early if your cloud function is that long, otherwise consider starting a lightweight Task and let the user wait for the result through live queries for example.

@wyantb
Copy link

wyantb commented Apr 22, 2021

For anyone finding this issue from google, note that you may be able to configure the max retries via the sdk using APIs like discussed in https://community.parseplatform.org/t/how-can-i-set-request-attempt-limit-or-another-request-params-for-cloud-functions/929 Parse.CoreManager.set('REQUEST_ATTEMPT_LIMIT', 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants