Node.js服务器正在崩溃而没有任何错误

时间:2014-10-07 05:45:19

标签: node.js

我正在使用边缘模块(https://github.com/tjanczuk/edge)从sql数据库中读取。功能如下:

function getBetweenRows(cb) {
    //console.log("lastcheckedID inside function ", lastCheckedID);
    //console.log("lastinsertID inside function ", lastInsertID);
    console.log("here 2");
    var query = {
        connectionString: "Data Source=localhost;Initial Catalog=db-name;Integrated Security=True",
        //source: "SELECT * FROM CustomerMaster WHERE CustomerID BETWEEN '" + lastCheckedID + "' AND '" + lastInsertID + "';"
                    source: "SELECT * FROM CustomerMaster WHERE CustomerID BETWEEN '2965' AND '2972';"
    };

    console.log("query is ", query.source);
    console.log("here 3");
    var getRows = edge.func('sql', query);
    console.log("here 4");
    getRows(null, function(error, result) {
    console.log("here 5");
        if (error) {
            console.log(error);
            throw error;
            log.error({rows:error});

        }
        rows = result;
        log.info({rows:rows});
        console.log(rows);
    console.log("here 6");

        cb(rows);
    });
}

有趣的是这段代码在其他一些系统上运行得很好。但是在这个特定的系统上,它打印到here 4然后服务器中断。它没有显示任何错误。我如何找出问题所在?

1 个答案:

答案 0 :(得分:0)

很抱歉,我不知道发布的内容在不同的系统上发生的情况有所不同,但如果您想调试并找到两个系统上的逐步差异,请使用节点调试器:

http://nodejs.org/api/debugger.html

值得了解。

此外,我注意到偶然的问题,在投掷错误时我无法解释。尝试在违规系统上注释抛出线(也许是log.js调用。)如果这样可以解决问题,你知道它与错误有关。

让我知道你发现了什么。