mirror of
https://github.com/mempool/mempool.git
synced 2025-04-04 09:58:36 +02:00
Fix unfurler navigation race condition
This commit is contained in:
parent
c289f821e4
commit
313d8d6a53
@ -97,15 +97,20 @@ class Server {
|
||||
throw new Error('failed to access open graph service');
|
||||
}
|
||||
}
|
||||
// wait for navigation to complete
|
||||
await page.waitForFunction(
|
||||
(path) => window.location.pathname.includes(path),
|
||||
{},
|
||||
path
|
||||
);
|
||||
// wait for preview component to initialize
|
||||
await page.waitForSelector('meta[property="og:preview:loading"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 })
|
||||
|
||||
const waitForReady = await page.$('meta[property="og:preview:loading"]');
|
||||
let success = true;
|
||||
if (waitForReady != null) {
|
||||
success = await Promise.race([
|
||||
page.waitForSelector('meta[property="og:preview:ready"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => true),
|
||||
page.waitForSelector('meta[property="og:preview:fail"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => false)
|
||||
])
|
||||
}
|
||||
success = await Promise.race([
|
||||
page.waitForSelector('meta[property="og:preview:ready"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => true),
|
||||
page.waitForSelector('meta[property="og:preview:fail"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => false)
|
||||
])
|
||||
if (success) {
|
||||
const screenshot = await page.screenshot();
|
||||
return screenshot;
|
||||
|
Loading…
x
Reference in New Issue
Block a user