Closed dhill-ss closed 6 years ago
The timeout is set to 3 minutes. My entire index.js is:
const setup = require('./starter-kit/setup');
exports.handler = async (event, context, callback) => {
// For keeping the browser launch
context.callbackWaitsForEmptyEventLoop = false;
const browser = await setup.getBrowser();
console.log('calling exports.run..');
exports.run(browser).then(
(result) => callback(null, result)
).catch(
(err) => callback(err)
);
};
exports.run = async (browser) => {
console.log('in exports.run..');
const page = await browser.newPage();
await page.goto('https://www.google.co.jp',
{waitUntil: ['domcontentloaded', 'networkidle0']}
);
console.log('after goto..');
console.log((await page.content()).slice(0, 500));
await page.screenshot({path: '/tmp/screenshots/google.png'});
console.log('after screenshot..');
await page.close();
return 'done';
};
Note: I found that when I set the Runtime to "Node.js 6.10" in the Function code area of the Lambda Configuration, it passes the part where it exited without error. Perhaps update the Documentation to include this step.
Has anyone else seen this start fine, run without error and then stop in the middle of the exports.run. If I modify the example code as follows:
I get the first console.log and not the second...
Any ideas?