工作云代码停止工作。代码没有变化

时间:2014-06-13 10:56:13

标签: javascript parse-platform

过去1个月我有一份预定的工作,工作得很好。但自6月4日以来,我开始收到“太多正在运行的工作”的错误。即使没有工作也没有。我甚至尝试过简单的Hello World工作,但也没有工作。我提交了一个错误,但它仍然在" Assigned"状态。

现在,如果我检查"工作状态"小组我有时会在两条特定的线(下面标记)中的任何一条线上出错,这条线的工作非常好。我也检查了我的旧提交,代码仍然是相同的。错误如下。

如果你能找到一些可疑的东西,请检查一下。我得到一个表" news_cat"并逐行发送该行以执行httpRequest。响应被发送到另一个函数,通过使用xmlreader.js(from here),我从对象收集链接,标题等,并将其保存到" ToiInter"类。请查看:

var xmlreader = require('cloud/xmlreader.js');
var ToiInter = Parse.Object.extend("ToiInter");


//Get urls from all the newspaper-category pairs
Parse.Cloud.job("job_get_data_for_all_newspapers", function (request, response) {
    //news_cat class contains the newspaper_category pairs 
    var newsCatList = Parse.Object.extend("news_cat");
    var query = new Parse.Query(newsCatList);                                                            
    query.find().then(function(list){
        // console.log("Successfully retrieved " + list.length);

        //create array and use Promise.when to wait till it is filled
        var promisesGetNP = [];
        for (var i = 0; i < list.length; i++) { 
            promisesGetNP.push(getDataForNewspaper(list[i].get("newspaper_id_column"), list[i].get("category_id_column"), list[i].get("url_column")));
        }
        return Parse.Promise.when(promisesGetNP);

    }).then (function(result) {
            // console.log("done job");
            response.success("Saving completed successfully.");
        },function(error) {
            console.log("job not done, error - "+error.message);
            response.error("Something went wrong.");
        }
    );
}); 

//get httpResponse from a url
function getDataForNewspaper(newspaperId, catId , feedUrl){
    console.log("getData NEW & CAT ID - " + newspaperId + ", "+catId+ " feedUrl "+feedUrl);

    //create array and use Promise.when to wait till it is filled
    var promisesGetData = []; 
    return Parse.Cloud.httpRequest({
        url: feedUrl
    }).then(function(httpResponse){
        promisesGetData.push(processDataForNewspaper(httpResponse, newspaperId, catId));
        return Parse.Promise.when(promisesGetData);

    }).then(function() {
        console.log("Done getData? ");
        return Parse.Promise.as("Got Data");
    });
}

function processDataForNewspaper(httpResponse, newspaperId, catId){
    console.log("processData NEW & CAT ID - " + newspaperId + ", "+catId);
    someXml = httpResponse.text

    //using xmlreader.js and sax.js to parse xml into text
    xmlreader.read(someXml, function (err, res){
        if(err) {
            return console.log(err);
        }   

        //create a new array and push objects with data in it       
        var listArray = [];
        res.rss.channel.item.each(function (i, item){
            var newsArt = new ToiInter();
            newsArt.set("link", item.link.text());      //get error here
            newsArt.set("title", item.title.text());    //or here
            newsArt.set("pubDate", item.pubDate.text());
            newsArt.set("newspaper_id",newspaperId);
            newsArt.set("cat_id",catId);
            listArray.push(newsArt);
        });

        //create a new promises array
        var promises = new Array();
        Parse.Object.saveAll(listArray, {
                success: function(objs) {
                    promises.push(objs);
                    console.log("SAVED ALL!");
                },
                error: function(error) { 
                    console.log("ERROR WHILE SAVING - "+error.message);
                }   
            });
        return Parse.Promise.when(promises);        
    });
}

ERROR:

E2014-06-13T10:55:15.843Z] v315: Ran job job_get_data_for_all_newspapers with:
  Input: {}
  Failed with: TypeError: Object [object Object] has no method 'text'
    at main.js:146:45
    at Object.object.each (xmlreader.js:137:6)
    at main.js:143:30
    at Object.saxparser.onend (xmlreader.js:104:10)
    at emit (sax.js:616:33)
    at end (sax.js:655:3)
    at Object.write (sax.js:917:30)
    at Object.SAXParser.close (sax.js:153:38)
    at Object.exports.read (xmlreader.js:157:29)
    at processDataForNewspaper (main.js:136:15)

0 个答案:

没有答案