node.js - Hitting Maximum call stack exceeded in Lambda functions -
i have nodejs lambda function runs set of tests in newman (a js library of postman). tests run when lambda trying send message codepipeline using codepipeline.putjobsuccessresult, keeps throwing maximum call stack exceeded error. printed error stack doesn't seem long (i can see 6 lines printed).
any how why stack trace exceeding , how debugged help.
relevant exports.handler
exports.handler = function(event, context) { var jobid = event["codepipeline.job"].id; console.log("triggering tests job "+ jobid); var putjobsuccess = function(message) { codepipeline.putjobsuccessresult({jobid: jobid}, (err, data) => { if (err) { context.fail(err); } else { context.succeed(message) } }); } var putjobfailure = function(message) { console.log("tests failed job: " + jobid); var params = { jobid: jobid, failuredetails: { message: json.stringify(message), type: 'jobfailed', externalexecutionid: "" } } } var testrunnercallback = function(response) { if (response === 1) { putjobfailure("tests failed. view logs details"); } else { putjobsuccess("all tests passed"); } } newman.execute(collections, newmanoptions, testrunnercallback); }
thanks
the context
has no success
or fail
method. use callback
parameter.
try this:
exports.handler = function(event, context, callback) { var jobid = event["codepipeline.job"].id; console.log("triggering tests job "+ jobid); var putjobsuccess = function(message) { codepipeline.putjobsuccessresult({jobid: jobid}, callback); } var putjobfailure = function(message) { console.log("tests failed job: " + jobid); var params = { jobid: jobid, failuredetails: { message: json.stringify(message), type: 'jobfailed', externalexecutionid: "" } } callback(params); } var testrunnercallback = function(response) { if (response === 1) { putjobfailure("tests failed. view logs details"); } else { putjobsuccess("all tests passed"); } } newman.execute(collections, newmanoptions, testrunnercallback); }
Comments
Post a Comment