ratson / puppeteer_plus

Deno port of puppeteer base on latest TypeScript source.
https://deno.land/x/puppeteer_plus
MIT License
20 stars 4 forks source link

`error: Uncaught TypeError: fileHandle.writeFile is not a function` #4

Closed jerrygreen closed 1 year ago

jerrygreen commented 2 years ago

After fixing https://github.com/ratson/puppeteer_plus/issues/2, I'm still not able to convert to pdf,

error: Uncaught TypeError: fileHandle.writeFile is not a function
      await fileHandle.writeFile(chunk);
                       ^
    at getReadableAsBuffer (https://raw.githubusercontent.com/jerrygreen/puppeteer_plus/issue_2/vendor/puppeteer/src/common/util.ts:459:24)
    at Object.runMicrotasks (deno:core/01_core.js:263:30)
    at processTicksAndRejections (https://deno.land/std@0.151.0/node/_next_tick.ts:62:10)
    at async Page.pdf (https://raw.githubusercontent.com/jerrygreen/puppeteer_plus/issue_2/vendor/puppeteer/src/common/Page.ts:3056:20)
    at async file:///home/ubuntu/Projects/html-to-pdf/html2pdf.ts:7:1

html2pdf.ts:

import puppeteer from "https://raw.githubusercontent.com/jerrygreen/puppeteer_plus/issue_2/mod.ts";

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://example.com");
await page.pdf({ path: 'file.pdf' })
await browser.close();

Deno.version:

{
   "deno": "1.24.3",
   "v8":" 10.4.132.20",
   "typescript": "4.7.4"
}

The issue is related to this code here, but I don't yet know how to get over it (I don't feel brave enough to investigate so deeply, but maybe someone else will solve it):

https://github.com/ratson/puppeteer_plus/blob/68223f46614434d2f089068e07c5b9ace05e52ba/vendor/puppeteer/src/common/util.ts#L456-L460

ratson commented 1 year ago

It will be fixed once the upstream has complete fs compat support. https://github.com/denoland/deno/issues/18218

salemalem commented 3 months ago

Any update? Having this error: TypeError: fileHandle.stat is not a function