dappeteer icon indicating copy to clipboard operation
dappeteer copied to clipboard

Can't use Headless mode

Open iyarsius opened this issue 3 years ago • 6 comments

When i call setupMetamask using headless mode, the function never ends. I don't have errors but i can't use it.

const browser = await dappeteer.launch(puppeteer, {
        metamaskVersion: 'v10.1.1',
        headless: true
});

console.log('Loading metamask...')
const metamask = await dappeteer.setupMetamask(browser);
console.log('logged !')
  • NodeJs version v16.8.0
  • dAppeteer version 2.2.0

iyarsius avatar Nov 24 '21 21:11 iyarsius

Hey @iyarsius It is a limitation of the puppeteer, there is nothing can we do about it :disappointed:

BeroBurny avatar Nov 25 '21 10:11 BeroBurny

How does MM itself test their own extension then? Full non-headless?

Elyx0 avatar Dec 23 '21 18:12 Elyx0

@Elyx0 - the problem is that MM is a Chrome extension - you cannot run Chromium/Chrome headless loaded with extensions: https://bugs.chromium.org/p/chromium/issues/detail?id=706008#c5

At most, you can run Chrome in non-headless mode, but with xvfb, which is an in-memory display server: https://www.mattzeunert.com/2018/07/21/running-headful-chrome-on-ubuntu-server.html

budowski avatar Dec 28 '21 15:12 budowski

npm i xvfb

const Xvfb = require('xvfb');

(async function() {
    let xvfb = new Xvfb();
    xvfb.startSync();
   
    // code here....

})();

it works for me.

marcelooblan2016 avatar Jan 06 '22 14:01 marcelooblan2016

I tried to create the launch dappeteer inside of the xvfb but i did not get a successful response I just get and error: Error: Could not start Xvfb. at Xvfb.startSync (/Users/user/Documents/Projects/scrappers/node_modules/xvfb/index.js:84:17) at /Users/user/Documents/Projects/scrappers/index.js:18:10 at /Users/user/Documents/Projects/scrappers/index.js:22:5 at Layer.handle [as handle_request] (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/layer.js:95:5) at next (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/layer.js:95:5) at /Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/index.js:341:12) at next (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/index.js:275:10)

Some one has another solution ?

sebastianBD95 avatar May 21 '22 01:05 sebastianBD95

I tried to create the launch dappeteer inside of the xvfb but i did not get a successful response I just get and error: Error: Could not start Xvfb. at Xvfb.startSync (/Users/user/Documents/Projects/scrappers/node_modules/xvfb/index.js:84:17) at /Users/user/Documents/Projects/scrappers/index.js:18:10 at /Users/user/Documents/Projects/scrappers/index.js:22:5 at Layer.handle [as handle_request] (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/layer.js:95:5) at next (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/layer.js:95:5) at /Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/index.js:341:12) at next (/Users/user/Documents/Projects/scrappers/node_modules/express/lib/router/index.js:275:10)

Some one has another solution ?

It seems like you have issue with xvfb and not dappeteer.

mpetrunic avatar May 21 '22 17:05 mpetrunic