deno-puppeteer icon indicating copy to clipboard operation
deno-puppeteer copied to clipboard

Buffer is not defined

Open itskreisler opened this issue 2 years ago • 5 comments

Error: Uncaught ReferenceError: Buffer is not defined ? Buffer.from(postData).toString("base64")

Reason:

//this happens when listening to the "request" event
browser = await puppeteer.launch({headless:false});
    const page = await browser.newPage();
    page.setDefaultNavigationTimeout(0);
    page.setRequestInterception(true);
    page.on("request", (interceptedRequest) => {
      interceptedRequest.continue({
        method: "POST",
        postData: new URLSearchParams(body).toString(),
        headers: {
          ...interceptedRequest.headers(),
          "Content-Type": "application/x-www-form-urlencoded",
        },
      });
    });
    await page.goto(url);

itskreisler avatar Feb 12 '23 21:02 itskreisler

Hello ! I ran into the same issue, did you find a solution ?

Roxxouille avatar Mar 01 '23 11:03 Roxxouille

Hello ! I ran into the same issue, did you find a solution ?

Not really, and I abandoned the project I was doing :(

itskreisler avatar Mar 06 '23 06:03 itskreisler

Deno doesn't have a Buffer like nodejs, that is the problem. You'd have to polyfill it.

Kreijstal avatar Apr 06 '23 11:04 Kreijstal

I have the same issue any solutions ? error: Uncaught ReferenceError: Buffer is not defined ? Buffer.from(postData).toString("base64") ^ at HTTPRequest._HTTPRequest_continue (https://deno.land/x/[email protected]/vendor/puppeteer-core/puppeteer/common/HTTPRequest.js:716:9) at HTTPRequest.continue (https://deno.land/x/[email protected]/vendor/puppeteer-core/puppeteer/common/HTTPRequest.js:508:9) at file:///home/ibrahim/cf403/index.ts:37:30 at https://deno.land/x/[email protected]/vendor/puppeteer-core/puppeteer/common/Page.js:533:20 at eventLoopTick (ext:core/01_core.js:181:11) at async HTTPRequest.finalizeInterceptions (https://deno.land/x/[email protected]/vendor/puppeteer-core/puppeteer/common/HTTPRequest.js:300:5)

ibrah3m avatar May 11 '23 12:05 ibrah3m

Hello! Ran into the same issue. Is it fair to say that appears for any intercepted request that sends back a customised response body?

lisahns avatar Dec 19 '23 08:12 lisahns