Skip to content

Commit 2d962b2

Browse files
committed
snapshot bugfixes
1 parent dedbfa4 commit 2d962b2

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

server/services/getChartSVG.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ function timeout(ms) {
66
};
77

88
(async() => {
9-
const browser = await puppeteer.launch();
10-
const page = await browser.newPage();
11-
await page.setViewport({width: 1920, height: 1080})
12-
await page.goto(process.argv[2], {waitUntil: 'networkidle2'});
13-
await timeout(1000)
14-
await page.screenshot({path: process.argv[3], clip: { x: 0, y: 0, width: 1150, height: 1080 }});
15-
browser.close();
9+
try {
10+
const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
11+
await timeout(1000)
12+
const page = await browser.newPage();
13+
await timeout(1000)
14+
await page.setViewport({width: 1920, height: 1080})
15+
await page.goto(process.argv[2], {waitUntil: 'networkidle2'});
16+
await timeout(1000)
17+
await page.screenshot({path: process.argv[3], clip: { x: 0, y: 0, width: 1150, height: 1080 }});
18+
browser.close();
19+
} catch (error) {
20+
console.error('Error occurred while generating chart SVG:', error);
21+
}
1622

1723
})();

server/services/snapshot/headstart_snapshot.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@
2727
data_config.options = options_<?php echo htmlspecialchars($_GET['service']); ?>.dropdowns;
2828
}
2929
</script>
30-
<script type="text/javascript" src="../../../dist/headstart.js"></script>
31-
<link type="text/css" rel="stylesheet" href="../../../dist/headstart.css"></link>
30+
<?php include "../../../dist/headstart.php"; ?>
3231
<script type="text/javascript">
33-
headstart.start();
32+
// Function to check if headstart is loaded and start it
33+
function initializeHeadstart() {
34+
if (typeof headstart !== 'undefined' && headstart.start) {
35+
headstart.start();
36+
} else {
37+
setTimeout(initializeHeadstart, 100);
38+
}
39+
}
40+
41+
// Wait for DOM to be ready, then start checking for headstart
42+
document.addEventListener('DOMContentLoaded', function() {
43+
// Give a small delay to ensure deferred scripts have time to load
44+
setTimeout(initializeHeadstart, 500);
45+
});
3446
</script>
3547
</body>
3648
</html>

0 commit comments

Comments
 (0)