@cumulus/cumulus-message-adapter-js
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -9,2 +9,7 @@ # Changelog | ||
## [v2.0.2] 2021-11-17 | ||
- **CUMULUS-2745** | ||
- Updates logging to always log CMA stderr on function timeout | ||
## [v2.0.1] 2021-09-28 | ||
@@ -11,0 +16,0 @@ |
@@ -32,3 +32,3 @@ "use strict"; | ||
/** | ||
* An error to be thrown when invokation of the cumulus-message-adapter fails | ||
* An error to be thrown when invocation of the cumulus-message-adapter fails | ||
*/ | ||
@@ -74,3 +74,5 @@ class CumulusMessageAdapterExecutionError extends Error { | ||
const cmaProcess = child_process_1.default.spawn(...spawnArguments); | ||
cmaProcess.on('error', () => { }); | ||
cmaProcess.on('error', () => { | ||
console.log(`CMA (on error) StdErr: \n ${errorObj.stderrBuffer}`); | ||
}); | ||
cmaProcess.stdin.setDefaultEncoding('utf8'); | ||
@@ -80,11 +82,12 @@ cmaProcess.stdout.setEncoding('utf8'); | ||
cmaProcess.on('close', () => { | ||
if (cmaProcess.killed !== true) { | ||
console.log(`CMA Exit Code: ${cmaProcess.exitCode} `); | ||
if (cmaProcess.exitCode !== 0) { | ||
console.log(`CMA Failure: ${errorObj.stderrBuffer}`); | ||
console.log(`CMA Exit Code: ${cmaProcess.exitCode} `); | ||
if (!(cmaProcess.killed === true && cmaProcess.exitCode === 0)) { | ||
console.log(`CMA StdErr: \n ${errorObj.stderrBuffer}`); | ||
if (cmaProcess.killed === true) { | ||
console.log('CMA Process killed'); | ||
} | ||
else { | ||
console.log('CMA exited with failure'); | ||
} | ||
} | ||
else { | ||
console.log('CMA process killed'); | ||
} | ||
}); | ||
@@ -179,2 +182,6 @@ cmaProcess.stderr.on('data', (data) => { | ||
}); | ||
const lambdaTimer = setTimeout(() => { | ||
console.log('Lambda timing out, writing CMA stderr to cloudwatch logs'); | ||
console.log(`CMA (on start task timeout) StdErr: \n ${errorObj.stderrBuffer}`); | ||
}, context.getRemainingTimeInMillis() - 5 * 100); | ||
try { | ||
@@ -190,3 +197,3 @@ cmaStdin.write('loadAndUpdateRemoteEvent\n'); | ||
if (!typeGuards_1.isCumulusMessageWithAssignedPayload(loadAndUpdateRemoteEventOutput)) { | ||
throw new Error(`Invalid output typing recieved from | ||
throw new Error(`Invalid output typing received from | ||
loadAndUpdateRemoteEvent ${JSON.stringify(loadAndUpdateRemoteEventOutput)}`); | ||
@@ -204,6 +211,8 @@ } | ||
if (!typeGuards_1.isLoadNestedEventInput(loadNestedEventOutput)) { | ||
throw new Error(`Invalid output typing recieved from | ||
throw new Error(`Invalid output typing received from | ||
loadNestedEvent ${JSON.stringify(loadNestedEventOutput)}`); | ||
} | ||
console.log('Starting task function'); | ||
const taskOutput = await TaskFunction(loadNestedEventOutput, context); | ||
console.log('Starting task function finished'); | ||
cmaStdin.write('createNextEvent\n'); | ||
@@ -220,6 +229,7 @@ cmaStdin.write(JSON.stringify({ | ||
if (typeGuards_1.isLoadNestedEventInput(createNextEventOutput)) { | ||
throw new Error(`Invalid typing recieved from | ||
throw new Error(`Invalid typing received from | ||
createNextEventOutput: ${JSON.stringify(createNextEventOutput)}`); | ||
} | ||
return createNextEventOutput; | ||
const returnVal = createNextEventOutput; | ||
return returnVal; | ||
} | ||
@@ -244,4 +254,7 @@ catch (error) { | ||
} | ||
finally { | ||
clearTimeout(lambdaTimer); | ||
} | ||
} | ||
exports.runCumulusTask = runCumulusTask; | ||
//# sourceMappingURL=cma.js.map |
{ | ||
"name": "@cumulus/cumulus-message-adapter-js", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Cumulus message adapter", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55413
461