server/ipad: Wait for loading spinner to be hidden before capturing page

This commit is contained in:
Adam Goldsmith 2023-11-03 14:41:10 -04:00
parent 1c096df395
commit 1151378708

View File

@ -22,8 +22,11 @@ app.get('/ipad.png', async (req, res) => {
frontend_url.searchParams.set('tool', req.query.tool);
}
await puppet_page.goto(frontend_url.toString());
// TODO: handle timeout
await puppet_page.waitForNetworkIdle({ timeout: 5000 });
// TODO: handle timeout better (ie present a better error to the frontend)
await puppet_page.waitForSelector('#loadingSpinner', {
hidden: true,
timeout: 10000,
});
const screenshot = await puppet_page.screenshot();
await puppet_page.close();
res.send(screenshot);