#Puppeteer through NPM fails to launch

17 messages · Page 1 of 1 (latest)

glacial owl
#

i'm trying to use puppeteer inside deno to be able to virtually render SVGs and calculate their rendered metrics. i'm importing puppeteer-core from NPM and using a local chromium binary that is functional. when i call:

    console.log("Using", chromiumPath);

    const browser = await PuppeteerNode.launch({
      executablePath: chromiumPath,
    });

it outputs

Using /usr/bin/chromium
error: Uncaught ErrorEvent {
  [Symbol(kTarget)]: WebSocket {
    _events: {
      open: [Function: onOpen] { [Symbol(kIsForOnEventAttribute)]: false, [Symbol(kListener)]: [Function] },
      error: [Function: onError] { [Symbol(kIsForOnEventAttribute)]: false, [Symbol(kListener)]: [Function] }
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    _binaryType: "nodebuffer",
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: Buffer(0) [],
    _closeTimer: null,
    _extensions: {},
    _paused: false,
    _protocol: "",
    _readyState: 3,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _url: "ws://127.0.0.1:45377/devtools/browser/11286f45-0a00-4d57-8db2-c9140d9b3abd",
    _originalIpc: false,
    _originalSecure: false,
    _originalHostOrSocketPath: "127.0.0.1:45377",
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: "error",
  [Symbol(kError)]: Error: Unexpected server response: 101
    at ClientRequest.<anonymous> (file:///home/skybl/.cache/deno/npm/registry.npmjs.org/ws/8.10.0/lib/websocket.js:886:7)
    at ClientRequest.emit (https://deno.land/std@0.166.0/node/_events.mjs:379:28)
    at ClientRequest._final (https://deno.land/std@0.166.0/node/http.ts:156:10),
  [Symbol(kMessage)]: "Unexpected server response: 101"
}
#

it works correctly on node, so i'm pretty sure this is a problem with deno

import puppeteer from "./node_modules/puppeteer-core/lib/esm/puppeteer/puppeteer-core.js";

const browser = await puppeteer.launch({
    executablePath: "/usr/bin/chromium",
});

const page = await browser.newPage();

await page.setContent("<html>hi</html>");

console.log(await page.content());
#

i'd really like to use this with deno, though, because it has a lot of useful APIs and things

hushed lotus
glacial owl
#

I did, i could post the whole code if you like. the part i posted is the only relevant part

#

the rest is finding the path to the chromium binary before the excerpt and creating a new page after it

glacial owl
willow sierra
#

The error is related to the stealth plugin, but this is an issue with puppeteer in general

glacial owl
#

ooooh

#

thank you so much for the heads up :D

#

guess i'm using node for this one /shrug
also darnit i should have searched before posting 😅

#

thank you again

willow sierra
glacial owl
#

yep