perf: switch to domcontentloaded default, optimize browser pool, fix swagger paths
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 7m59s
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 7m59s
Performance fixes: - Default waitUntil changed from networkidle2 to domcontentloaded (saves ~500ms+) - Add waitUntil parameter so users can choose (load/domcontentloaded/networkidle0/networkidle2) - Optimize page recycle: use DOM reset instead of about:blank navigation - Add Chromium flags to disable unnecessary features (background networking, extensions, sync, etc.) Swagger fixes: - Fix apis glob to include dist/*.js (was only matching src/*.ts, empty at runtime) - Document new waitUntil parameter on POST /v1/screenshot - Add OpenAPI docs for /status endpoint
This commit is contained in:
parent
de1215bc32
commit
d20fbbfe2e
5 changed files with 43 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ export interface ScreenshotOptions {
|
|||
waitForSelector?: string;
|
||||
deviceScale?: number;
|
||||
delay?: number;
|
||||
waitUntil?: "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
|
||||
}
|
||||
|
||||
export interface ScreenshotResult {
|
||||
|
|
@ -34,6 +35,7 @@ export async function takeScreenshot(opts: ScreenshotOptions): Promise<Screensho
|
|||
const fullPage = opts.fullPage ?? false;
|
||||
const quality = format === "png" ? undefined : Math.min(Math.max(opts.quality || 80, 1), 100);
|
||||
const deviceScale = Math.min(opts.deviceScale || 1, 3);
|
||||
const waitUntil = opts.waitUntil || "domcontentloaded";
|
||||
|
||||
const { page, instance } = await acquirePage();
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ export async function takeScreenshot(opts: ScreenshotOptions): Promise<Screensho
|
|||
|
||||
await Promise.race([
|
||||
(async () => {
|
||||
await page.goto(opts.url, { waitUntil: "networkidle2", timeout: 20_000 });
|
||||
await page.goto(opts.url, { waitUntil, timeout: 20_000 });
|
||||
|
||||
if (opts.waitForSelector) {
|
||||
await page.waitForSelector(opts.waitForSelector, { timeout: 10_000 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue