puppeteer makes script to hang for a while at the end
I am using
npm:puppeteer
in my script. Everything is working fine. But often the script hangs at the end of the exit. Is this normal with puppeteer?
I think that some async op is leaking. But I am not sure if I made any mistake or it is coming from puppeteer. I do call browser.close()
in a finally
block.19 Replies
Could you share some code?
There's also a deno puppeteer which might fix your problems
@lino-levan here is a code reproducing the behavior on my machine.
I am actually using
puppeteer-extra
for fortified browser. the same behavior persists.
@jeff.hykin I can confirm import puppeteer from "https://deno.land/x/puppeteer@16.2.0/mod.ts";
solves the issue. π but I need to use puppeteer-extra
for fortification. π¦
hey @lino-levan thanks for suggesting astral. looks like it is fortified by default. π https://bot.sannysoft.com tests are passed
but astral is not customizable enough like puppeteer π¦ I need to start the browser with proxy and send page.evaluate()
with function arguments.
but nonetheless, it looks solid. maybe I will come back to it later πprobably worth opening an issue!
Have you tried setting the
HTTP_PROXY
env var? It works for me in Astral.
Released a new update with function arguments to page.evaluate()
. Let me know if you run into any other blockers.ooh awesome! @lino-levan if you're the maintainer, let me look into it more and open issues π
Would love feedback on the project. I think browser automation libraries should be hardened by default, no configuration neccessary.
btw, I will try with HTTP_PROXY, but can you please add support for argument passing for browser executable? like for chrome, I can just pass
--proxy-server=${proxyUrl}
. no pressure πThis isn't portable unfortunately. I'm hoping to get FF/Safari support going pretty soon and they don't have equivalents.
HTTP_PROXY
seems to be portable accross both chrome and FF at leastI meant, passing argument to browser executable in general. I am fine with passing proxy-server argument by myself.
like, this can have another field called
browserArgs?: string[]
.GitHub
astral/src/browser.ts at main Β· lino-levan/astral
A high-level puppeteer/playwright-like library for Deno - lino-levan/astral
Would probably be in
LaunchOptions
, but that sounds more than reasonable. I'll open a PR.Any other immediate feedback? Would love to roll this out into a new release.
I have the same issue with puppeteer. In fact I filed an issue here: https://github.com/denoland/deno/issues/20179
@lino-levan awesome! with your latest commit, I managed to completely move from puppeteer to astral π» only thing I missed is
waitUntil
in Page.goto()
ref. https://github.com/puppeteer/puppeteer/blob/2fee2b0adc7fd5f26c7b1d75a3efa29c2fe12dab/packages/puppeteer-core/src/common/Frame.ts#L109GitHub
puppeteer/packages/puppeteer-core/src/common/Frame.ts at 2fee2b0adc...
Node.js API for Chrome . Contribute to puppeteer/puppeteer development by creating an account on GitHub.
also, I was using
.$$eval
before - which is not available in astral. but I worked it around by just using .evaluate
. so it's not a biggie πI believe
page.goto
takes in a GoToOptions
which includes a waitUntil
(of type "load" | "networkidle0" | "networkidle2"
).ah. I was getting errors because I was using
"domcontentloaded"
. all good in that case π