Api response buffering indefinitely

App ID: DD9FC30D-3A6F-AB4C-FF9C-24DC92E73100

Continuing my post on the Slack Support Channel:

Posted 10/24/22 @ 12:03 PM EST
Hello, I have gotten a redis error when running both ‘npm run debug’ and ‘npm run deploy’. I don’t think this was an issue with our codebase because I get the error even when I download and run a brand new project template. I will reply to this message with the error. Please help as it is stopping development and testing.

The above issue was resolved, but I added it because it may have relevance to the existing issue.

Posted 10/24/22 @ 9:45 PM EST
Nothing seems to be returning for my cloud code api calls. At first I though I was misusing the non-blocking function incorrectly, but I placed a ‘return 0;’ at the top of the function and still nothing. I also have run calls that have worked in the past. The response section on the right side of the cloud code → api services just buffers for many minutes and eventually times out. Any ideas?

Post next day @ 12:45 PM EST
The issue still persists. My console will print everything in my api function, up to the return statement. And I get a “Processing finished” as normal (always shown in your api calls) printed to my console. I still just don’t get a response in the backendless interface online.

Here are some API function attempting to be called, but note that I have changed functions to return zero on the first line and the same issu is present. I have also changed the @return tag to many different combos.

/**
 * 
 * @param {Church} church 
 * @returns {Promise.<Church>}
 */
addChurch(church) {
    var church_params = Church.getProperties(church);
    church_params = Church.validateProperties(church_params)
    // auth related to depreciated kumulos functions
    // if(!AuthService.isSuperUser(authUser.userID)) {
    //     throw new ForbiddenError('Only a super user can create a church.');
    // }
    return Backendless.Data.of('churches').save(church_params, true)
}

/**
 * 
 * @param {Array.<Church>} churches 
 * @ returns {Promise.<void>}
 */
addChurches(churches) {
    // var validator = new Validator(churches);
    // var params = validator
    //     .notNull('churches')
    //         .json('churches')
    //     .getParams();

    //K.transaction.start();
    // if(!AuthService.isSuperUser(authUser.userID)) {
    //     throw new ForbiddenError('Only a super user can create churches.');
    // } 

    // ChurchService.addChurches(params.churches);

    churches.forEach(church => this.addChurch(church));
}

Heres a function where a promise is not returned:

/**
 * @param {String} email
 * @param {String} password
 * @param {String} firstName
 * @param {String} lastName
 * @param {String} phone
 * @param {String} profilePic
 * @param {String} birthdate
 * @param {Number} churchID
 * @param {Number} build
 * @returns {Church}
 */
registerUser(email, password, firstName, lastName, phone, profilePic,
    birthdate, churchID, build) {
    // process and validate inputs
    var params = UserSupport.get_registry_params(email, password, firstName,
        lastName, phone, profilePic, birthdate, churchID, build);
    params = UserSupport.validate_registry_params(params);

    // if user exists (by phone #)
        // update the user
        // if churchID is given 
            // update member status
        // send verification text
        // return the user
    // if phone does not exist
        // set user.registered = 1
        // user.lastChurchID = churchID (param), or equal to 0 if null or empty
        // churchSupport.requestMembership
        // send verification text
        // return the user

    // determine if phone exists
    var where_clause = "phone = " + params.phone;
    var query_builder = Backendless.DataQueryBuilder.create()
        .setWhereClause(where_clause);
    var query = Backendless.Data.of("users").findFirst(query_builder, true)
        .then((query) => {return query})
        .catch((error) => {console.error(error)})
    
    const print_addy = () => {
        query.then((q) => {
            console.log(q);
            return q;
        });
    };
    var addy = print_addy();
    console.log(addy);
    return print_addy();
}

I will get a console response that shows everything is working fine such as:

12:57:38.874 [master] Connection to Redis…
12:57:38.972 [master] Connection with Redis has been established
12:57:38.973 [master] Registering Code Runner on https://api.backendless.com
12:57:39.235 [master] Runner successfully registered.
12:57:39.236 [master] Registering Model on https://api.backendless.com
12:57:40.253 [master] Model successfully registered
12:57:40.253 [master] Waiting for Server Code tasks…
12:57:46.902 [master] [96DE5325-B8F9-582B-FFE1-897D183D0C00] New task arrived!
12:57:46.905 [master] [96DE5325-B8F9-582B-FFE1-897D183D0C00] [INVOKE SERVICE] services.ChurchService.addChurch
12:57:47.282 [master] [96DE5325-B8F9-582B-FFE1-897D183D0C00] Processing finished

1 Like

Hi @Noah_Caldwell

Could you please provide Steps to Reproduce the issue with minimum code?

Btw, instead of this:

const print_addy = () => {
        query.then((q) => {
            console.log(q);
            return q;
        });
    };
    var addy = print_addy();
    console.log(addy);

    return print_addy();
}

I can recommend you use async/await

async registerUser(email, password, firstName, lastName, phone, profilePic,
    birthdate, churchID, build) {
....

    const result = await query

    console.log('result', result);

    return result
}