Giter Site home page Giter Site logo

node-xvfb's People

Contributors

0x41mmarvm avatar korczis avatar rob--w avatar spacek33z avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-xvfb's Issues

Question about running multiple displays in same process

Hi,

Thanks for the useful package. I had a question about this use case:

Is it possible to use multiple different displays in the same node process? My understanding is each time we call startSync(), it spawns a Xvfb process and sets the parent process DISPLAY env var to the new display num. I think this means all the code in the parent process will start using the most recently spawned Xvfb process display right, even if a function called startSync() before to create another display?

Is there a way to create isolation so I can use different displays in the same node process? e.g.

async function a() {
  xvfb.startSync();
  
  // code that uses the virtual frame buffer here
  
  xvfb.stopSync();
}
// note: executed in parallel
await Promise.all([
  a() // uses display 1
  a() // uses display 2
]);

Cannot set displayNum: 0

Title says it all. Constructor option displayNum is not taken into account if value is set to 0.

"Could not start Xvfb" - windows 10

Hi

I am running it on windows, and it wont start. I think this is because it can't create the lockfile.
Do you know a quick way around this?
I'm using the synchronous functions with protractor js.

Also worth noting I'll only be running 1 instance of this at a time so I dont think I need the lockfile part.

Thanks

Cannot build on node 12

Sleep version 3 does not compile with node 12. Is it possible to update it to a newer version?

stopSync() blocks and never resumes if an error was thrown when initializing

var xvfb;
try
    Xvfb = require('xvfb');
    xvfb = new Xvfb({
      displayNum: 9,
      reuse: true,
      silent: false
    })
    xvfb.startSync()
  catch e
    console.log e

...

xvfb.stopSync()
console.log "Done!"

(coffeescript)

If it enters the catch, when it gets to stopSync() the node application will hang - "Done!" will not be printed.

'str::runtime_error' after several week of using library on production env

I used this library inside a docker container for several weeks and everything was OK until today. Now when my service try to initialize an XVFB I got an error like this, server is restarted and it's happening again:

Listening on port 3200...

terminate called after throwing an instance of 'std::runtime_error'
  what():  eglInitialize() failed.

Listening on port 3200...

I need to rebuild my container and after this operation, the container starts working again, and this error doesn't appear.

I use node-xvfb in version 0.3.0

Error with latest version of puppeteer

Hello,

Thanks for your library. I am using it with puppeteer like this:

const puppeteer = require('puppeteer');
const Xvfb      = require('xvfb');

var xvfb        = new Xvfb({silent: true});
var options     = {
  headless: false,
  args: [
    '--disable-infobars',
    '--no-sandbox',    
    '--shm-size=1gb',
    '--disable-dev-shm-usage',
  ],
}


async function main(){
  xvfb.startSync()
  const browser = await puppeteer.launch(options);
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});

  await browser.close();
  xvfb.stopSync()
}

main()

But I am getting errors like this:

(node:25099) UnhandledPromiseRejectionWarning: Error: Navigation failed because browser has disconnected!
    at CDPSession.LifecycleWatcher._eventListeners.helper.addEventListener (/root/bbb-recorder/node_modules/puppeteer/lib/LifecycleWatcher.js:46:107)
    at emitNone (events.js:106:13)
    at CDPSession.emit (events.js:208:7)
    at CDPSession._onClosed (/root/bbb-recorder/node_modules/puppeteer/lib/Connection.js:215:10)
    at Connection._onClose (/root/bbb-recorder/node_modules/puppeteer/lib/Connection.js:138:15)
    at WebSocketTransport._ws.addEventListener.event (/root/bbb-recorder/node_modules/puppeteer/lib/WebSocketTransport.js:48:22)
    at WebSocket.onClose (/root/bbb-recorder/node_modules/puppeteer/node_modules/ws/lib/event-target.js:124:16)
    at emitTwo (events.js:126:13)
    at WebSocket.emit (events.js:214:7)
    at WebSocket.emitClose (/root/bbb-recorder/node_modules/puppeteer/node_modules/ws/lib/websocket.js:191:10)
  -- ASYNC --
    at Frame.<anonymous> (/root/bbb-recorder/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.goto (/root/bbb-recorder/node_modules/puppeteer/lib/Page.js:672:49)
    at Page.<anonymous> (/root/bbb-recorder/node_modules/puppeteer/lib/helper.js:112:23)
    at main (/root/bbb-recorder/test.js:25:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:25099) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:25099) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any suggestion please?

Problem with Puppeteer and app in nodejs

Hi Rob
Sorry for my English
I have been working on this issue for two days and I do not leave, to see if you can help me or give me some clues to follow.
On a VPS with Centos8, I have an application running and scraping with Puppeteer every 15 minutes. It works well.
Now I need to get data from a web that throws me if I don't make the browser visible, but since the VPS doesn't have a screen, I had thought of Xvfb for this purpose.
However, I always get following error:
Error: spawn Xvfb ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn Xvfb',
path: 'Xvfb',
spawnargs: [ ':99', '-screen', '0', '1920x1080x24', '-ac' ] }

My app is installed in a folder in which only the Puppeteer module, in node_modules, is installed as an extra
Now i do
npm install xvfb
without errors

Start this part of the application with:
//load puppeteer and xvfb
const puppeteer = require('puppeteer');
const Xvfb = require('xvfb');
const count = 80;
let xvfb, browser, page;
//routine extract data
(async () =>
{
xvfb = new Xvfb({silent: true, xvfb_args: ["-screen", "0", '1920x1080x24', "-ac"]});
xvfb.start((err)=>{if (err) console.error(err)})
browser = await puppeteer.launch({headless: false,defaultViewport: null,args: ['--no-sandbox', '--start-fullscreen', '--display='+xvfb._display]});
page = await browser.newPage();
..................
........................
...............
await browser.close();
xvfb.stop();
})();

I have tried thousands of things, keeping track of errors, changing the index.js to cypress and others, and reading all the documentation on 'spawn'.
In addition to keeping track of all permissions, locations, paths, etc, etc ..
I can't find why spawn can't find 'Xvfb' which has just been exported "module.exports = 'Xvfb'"
If you can give me any indication I would be very grateful
Greetings and thanks

XIO: fatal IO error 0 (No error information) on X server ":9"

Hi @Rob--W ,

do you have any clue regarding this error? First run work flawlessly then the second function call regularly prints out the below error.

XIO:  fatal IO error 0 (No error information) on X server ":9"
      after 60 requests (60 known processed) with 0 events remaining.

Source javascript code:

  const Xvfb = require('xvfb');
  const xvfb = new Xvfb({
    displayNum: 9,
    reuse: false,
  });

  xvfb.startSync();

  ...

  xvfb.stopSync();

Thanks in advance

_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.

Hi! I like your simple architecture.

So, I would like to use your system,
but I get below errors...

Do you have any help?
(I'm sorry that it may not be no related to your system.)

2016-03-06T06:58:54.705407+00:00 app[web.1]: _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
2016-03-06T06:58:54.705420+00:00 app[web.1]: Initializing built-in extension SHAPE
2016-03-06T06:58:54.705422+00:00 app[web.1]: Initializing built-in extension XTEST
2016-03-06T06:58:54.705424+00:00 app[web.1]: Initializing built-in extension XKEYBOARD
2016-03-06T06:58:54.705424+00:00 app[web.1]: Initializing built-in extension XC-MISC
2016-03-06T06:58:54.705425+00:00 app[web.1]: Initializing built-in extension SECURITY
2016-03-06T06:58:54.705426+00:00 app[web.1]: Initializing built-in extension XINERAMA
2016-03-06T06:58:54.705427+00:00 app[web.1]: Initializing built-in extension XFIXES
2016-03-06T06:58:54.705427+00:00 app[web.1]: Initializing built-in extension RENDER
2016-03-06T06:58:54.705428+00:00 app[web.1]: Initializing built-in extension RANDR
2016-03-06T06:58:54.705429+00:00 app[web.1]: Initializing built-in extension DAMAGE
2016-03-06T06:58:54.705430+00:00 app[web.1]: Initializing built-in extension MIT-SCREEN-SAVER
2016-03-06T06:58:54.705431+00:00 app[web.1]: Initializing built-in extension DPMS
2016-03-06T06:58:54.705432+00:00 app[web.1]: Initializing built-in extension Present
2016-03-06T06:58:54.705433+00:00 app[web.1]: Initializing built-in extension DRI3
2016-03-06T06:58:54.705433+00:00 app[web.1]: Initializing built-in extension X-Resource
2016-03-06T06:58:55.215321+00:00 app[web.1]: /app/ubi/xkbcomp: error while loading shared libraries: libxkbfile.so.1: cannot open shared object file: No such file or directory
2016-03-06T06:58:55.219100+00:00 app[web.1]: (EE) 
2016-03-06T06:58:55.219100+00:00 app[web.1]: Fatal server error:
2016-03-06T06:58:55.219101+00:00 app[web.1]: (EE) Failed to activate core devices.(EE) 

"Could not start Xvfb"

I'm getting the error Could not start Xvfb. when trying to spin up xvfb. I'm attempting to use xvfb with nightmare as such:

var Xvfb = require('xvfb');
var Nightmare = require('nightmare');

var xvfb = new Xvfb();
xvfb.startSync();

var nightmare = Nightmare({
    show: false,
    webPreferences: {
        partition: 'custom'
    }
});

nightmare
    .goto('https://google.com')
    .evaluate(function () {
        return document.title;
    })
    .then(function (title) {
        console.log(title);
    }).end();

xvfb.stopSync();

However, it's failing on attempting to get xvfb up and running.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.