(Created on )

Puppeteer: 'height' in 'clip' must be positive.

Screenshot clip height is zero or negative.


Screenshot clip height is zero or negative.

Error message

'height' in 'clip' must be positive.

How this error happens

A screenshot rectangle must have a positive height. A zero-sized region contains no image to capture.

The snippets use an open Puppeteer page named page.

await page.screenshot({
    clip: {
        x: 0,
        y: 0,
        width: 640,
        height: 0,
    },
});

How to fix

Use a positive height and validate calculated dimensions before passing them to Puppeteer.

await page.screenshot({
    clip: {
        x: 0,
        y: 0,
        width: 640,
        height: 480,
    },
});

Things to keep in mind

If the dimensions come from an element, wait for its layout rather than substituting an arbitrary size.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →