Comments (15)
same problem here
from node-headless.
@GautierT use xvfb package instead, look at this comment: segment-boneyard/nightmare#602 (comment)
from node-headless.
@mateuszmazurek : Thanks ! Just got it working this morning with xvfb !
But as soon as i call the script multiple time some of them fail with timeout error.
Did u try running multiple script where each one have his own display on the same machine ?
from node-headless.
@GautierT currently I have one Xvfb process started by xvfb-run
and one script where i use xvfb
module = 2 displays in total (:99 permanently and :100 when running nightmare inside script). They work ok. That's all i can say at this moment.
from node-headless.
Okay thanks !
3 days that i try to understand how to launch multiple nightmare script on the same machine without timeout/crash... :(
from node-headless.
How many instances you need to run to make it crash? 2 or more? Did you try to use reuse
option?
from node-headless.
When i launch the script 4 or 5 times some of then will crash (Last line of nightmare log : nightmare:log crashed [{},false]
)
And after the timeout delay nightmare send me a timeout error : Error: .wait() timed out after 180000msec
And i think that when one of the script crash all electron process are killed so the other running script stop too...
from node-headless.
Hmm... Maybe you have no enough RAM? Why do you need to run this script multiple times in parallel?
from node-headless.
Because it's a script launch by user when the visit a url of my website. And multiple user can access this url at the same time.
Probably a ram problem yeah..
I don't see any other alternative to handle this case. I need this script launched when an user access the page to send him back some screenshot and files...
from node-headless.
Can't you just launch this script once and there create http server (maybe with express
) which will create new nightmare instance for every user request?
from node-headless.
That's what i do ! I have an expressjs server running. And when someone go to /api/scripts/script_name a function creating a new Xvfb() and a new Nightmare() is launched. But if i go to this url 5 times at the same time some of the script will never finish (timeout or crash) in no particular order. 4 times : sometimes all script finish well sometimes not !
Thanks for trying man ! I'm feeling less alone !
from node-headless.
Try to run you whole process inside Xvfb using xvfb-run
tool without using node-xvfb
module inside your script. If it won't help (95% sure it won't because it's simply problem with lack of RAM, not with node-xvfb
) you should queue your user's requests. To do so you can use promise-queue
package.
Example:
// at the top of your script
const Queue = require('promise-queue');
const queue = new Queue(1, Infinity); // change 1 with the number of concurrent requests you want to handle
...
// inside express request callback
queue.add(() => {
const nightmare = new Nightmare({
//show: true,
webPreferences: {
partition: 'nopersist'
}
});
console.log('nightmare started')
return
nightmare.goto('http://www.google.fr')
// ..... other instruction....
.then(() => {
// do sth
});
});
from node-headless.
I will try that ! Thanks !
Why do you think it's better to run the whole nodejs/expressjs with xvfb-run instead of using node-xvfb in script ?
from node-headless.
It's not better, I'm proposing to test it just to be 100% sure that it's not problem with node-xvfb.
from node-headless.
Thanks a lot @mateuszmazurek. The queue work very well... I run it with 1 concurrency and i used node-xvfb and the cpu goes between 40 and 60%. And the script goes pretty fast !
(I used async.queue)
I will try with xvfb-run to test the cpu.
Thanks again.
from node-headless.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-headless.