I have a Lambda function that I'm calling using API gateway. When the Lambda hits the spawn call on a child_process object the API Gateway immediately fails with a 504 timeout error. My timeout setting on the the API gateway is the max 30 seconds and the Lambda is set for a minute. It only takes up to 1400ms for the lambda to run, but it still reports timeout in the API. The Lambda runs successfully after the API Gateway gets the 504.
This happens during a call to FFMPEG and to a call to resize an image with the Sharp library. This happens whether I use synchronous or asynchronous calls.
function resizeVideo(next) {
var ffmpegOutput = exec.spawnSync('ffmpeg', [
'-i', tmpFilePath,
'-f', 'image2',
'-frames:v', '1',
'-filter:v', 'scale=w=-1:h=' + MAX_HEIGHT + ":force_original_aspect_ratio=decrease",
'pipe:1'
]);
console.log(ffmpegOutput.stderr);
next(null, JPG_CONTENT_TYPE, ffmpegOutput.stdout);
}
Any thoughts would be appreciated. Thanks!
exec.spawnSyncand the type of error just isn't propagated correctly? wrapexec.spawnSyncin a try-catch and find out. - Geert-Jan