When running the following code I keep getting a type error of `readable is not async iterable`, I n

When running the following code I keep getting a type error of readable is not async iterable, I narrowed it down to the const pdf = await page.pdf(); line but have no clue how I could resolve the issue. Anyone that could help me?

export interface Env {
    MYBROWSER: Fetcher;
}

import puppeteer from '@cloudflare/puppeteer';

export default {
    async fetch(request: Request, env: Env): Promise<Response> {
        const { searchParams } = new URL(request.url);
        let url = searchParams.get('url');

        // skip favicon requests
        if (request.url.includes('/favicon.ico')) return new Response('Not found', { status: 404 });

        if (url) {
            const browser = await puppeteer.launch(env.MYBROWSER);
            const page = await browser.newPage();
            await page.goto(url);

            const pdf = await page.pdf();

            await browser.close();

            if (!pdf) return new Response('No pdf found', { status: 404 });

            return new Response(pdf, {
                headers: {
                    'content-length': pdf.byteLength.toString(),
                    'content-type': 'application/pdf',
                },
            });
        } else {
            return new Response('Please add the ?url=https://example.com/ parameter');
        }
    },
};
Was this page helpful?