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
|
|
@ -70,6 +70,14 @@ export const screenshotRouter = Router();
|
|||
* maximum: 5000
|
||||
* default: 0
|
||||
* description: Extra delay in ms after page load before capturing
|
||||
* waitUntil:
|
||||
* type: string
|
||||
* enum: [load, domcontentloaded, networkidle0, networkidle2]
|
||||
* default: domcontentloaded
|
||||
* description: >
|
||||
* Page load event to wait for before capturing.
|
||||
* "domcontentloaded" (default) is fastest for most pages.
|
||||
* Use "networkidle2" for JS-heavy SPAs that load data after initial render.
|
||||
* examples:
|
||||
* simple:
|
||||
* summary: Simple screenshot
|
||||
|
|
@ -122,7 +130,7 @@ export const screenshotRouter = Router();
|
|||
* schema: { $ref: "#/components/schemas/Error" }
|
||||
*/
|
||||
screenshotRouter.post("/", async (req: any, res) => {
|
||||
const { url, format, width, height, fullPage, quality, waitForSelector, deviceScale, delay } = req.body;
|
||||
const { url, format, width, height, fullPage, quality, waitForSelector, deviceScale, delay, waitUntil } = req.body;
|
||||
|
||||
if (!url || typeof url !== "string") {
|
||||
res.status(400).json({ error: "Missing required parameter: url" });
|
||||
|
|
@ -140,6 +148,7 @@ screenshotRouter.post("/", async (req: any, res) => {
|
|||
waitForSelector,
|
||||
deviceScale: deviceScale ? parseFloat(deviceScale) : undefined,
|
||||
delay: delay ? parseInt(delay, 10) : undefined,
|
||||
waitUntil: ["load", "domcontentloaded", "networkidle0", "networkidle2"].includes(waitUntil) ? waitUntil : undefined,
|
||||
});
|
||||
|
||||
res.setHeader("Content-Type", result.contentType);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue