Giter Club home page Giter Club logo

electron-screenshot-service's People

Contributors

adig avatar asafyish avatar bumbu avatar fweinb avatar jerbob92 avatar peerbolte avatar zeke 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  avatar  avatar

electron-screenshot-service's Issues

count is not updated when a spawned process crashes

Hi,

When using electron-screenshot-service, sometimes the electron process crashes for unknown reasons, that's not a problem on it's own, but electron-screenshot-service doesn't decrease the count, so the next screenshot call fails.

Will you accept a PR for that ? it will move startElectron into createBrowser because it's needs acces to count.

electron-service missing version number in package.json

Potentially related to #30, but I'm getting the following error when installing this as a dependency:

> cd ./electron-service && npm install .

npm ERR! addLocal Could not install /usr/local/lib/node_modules/d3plus-dev/node_modules/electron-screenshot-service/electron-service
npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/7.0.0/bin/node" "/usr/local/bin/npm" "install" "."
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8

npm ERR! No version provided in package.json
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/lib/node_modules/d3plus-dev/node_modules/electron-screenshot-service/electron-service/npm-debug.log
/usr/local/lib
└── (empty)

Looks like NPM might require all package.json files to include a version number?

No compatible version found: axon@'^2.0.2'

Hello I am new with node and npm

I have this error:

npm ERR! Error: No compatible version found: axon@'^2.0.2'
npm ERR! Valid install targets:
npm ERR! ["0.0.3","0.1.0","0.2.0","0.3.0","0.3.1","0.3.2","0.4.0","0.4.1","0.4.2","0.4.3","0.4.4","0.4.5","0.4.6","0.5.0","0.5.1","0.5.2","0.6.0","0.6.1","1.0.0","2.0.0","2.0.1","2.0.2","2.0.3"]

I want test this library how can I do ?

Caching

It seems the javascript assets are very aggressively cached. Is there a way to disable caching as at the moment I have to add a random query string on the end of the src of my script tag each time i want screenshots with fresh JS.

Uncaught (in promise) TypeError: Bad argument(…)

I try to run the example code (https://github.com/FWeinb/electron-screenshot-service#usage) with node 6.5.0, Chromium 53.0.2785.113, Electron 1.4.1 and I got the following error:

internal/child_process.js:289 Uncaught (in promise) TypeError: Bad argument(…)ChildProcess.spawn @ internal/child_process.js:289exports.spawn @ child_process.js:392spawn @ index.js:17(anonymous function) @ browser.js:79_tickCallback @ internal/process/next_tick.js:103 internal/child_process.js:289 Uncaught (in promise) TypeError: Bad argument(…)ChildProcess.spawn @ internal/child_process.js:289exports.spawn @ child_process.js:392spawn @ index.js:17(anonymous function) @ browser.js:79_tickCallback @ internal/process/next_tick.js:103

Any ideas? Thanks in advance

Pass cookies

Is there a way to pass page cookies?
It could be done by tweaking electron-screenshot-app, but is there a better/simpler way?

Problem with error propagation?

I was rendering http://sassylists.com/documentation.html (domain doesn't exist anymore) and a popup shown me this error:

Uncaught Exception:
TypeError: Cannot read property 'id' of null
    at makeScreenshot (sassdoc.github.io/node_modules/electron-screenshot-service/electron-service/node_modules/electron-screenshot-app/index.js:58:44)
    at Timer.listOnTimeout (timers.js:89:15)

Also in the console output, I could log an error {} (literally an empty object).

So maybe there's an error at some level with error propagation?

Running as a service: won't create second screenshot

Firstly, this is a great module! I'm using it as part of a task runner to build a site then create a screenshot by calling this as a service at a given URL.

The issue is that it works the first time I call the URL but subsequent calls just hang. It gets to the screenshot creation, doesn't create a screenshot and then keeps trying over and over again.

I'm guessing that it's something to do with not closing the old process? But I thought that would be what screenshot.close(); does and I'm calling that right after the screenshot is saved.

I'm using express as a server that listens for a particular URL to generate screenshots. Have you seen anything like this before?

Feature Request: Inject JavaScript

Similar to how we inject CSS. Possible? Also is there an easy way to select specific dom elements to capture? I could do a hide all and show only what I want but I'd like a better way to specify dom capture.

Not Working on Heroku Deployment

My test is working on my local server (I'm running OSX,) but it is not working on my Heroku dyno (Linux)

I tried removing "." from "./" in my output
I also tried swapping "./" with __dirname

Neither worked, and I'm receiving an application error on my Heroku

Allow more options to pass to electron ?

Hi,

I want to supply electron with more options then just width/height/crop, but it seems the electron process is spawned with just those options, and doesn't except anything else...
I think it can be really helpful.

Clustering and zombie processes

Hi there,
I'm using this library together with the node cluster module to get a higher performance.
I had the issue that after a while no screenshot process was responding, because it was still busyot stuck, that why I'm killing the worker after about one hour. But the screenshot processes which were stuck are not getting killed, they remain as zombie processes.
I tried to use ps tree, to kill all children before killing the worker, but the electron processes were started as a child of the master process instead of the child process.
How can I prevent the zombie processes or I am closing the electron process not correctly?

This is a simplified version of my entry file.

if (cluster.isMaster) {
  log.info(`Master ${process.pid} is running`);

  // Fork workers.
  for (let i = 0; i < numCPUs; i++) {
    createFork();
  }

  cluster.on('exit', (worker, code, signal) => {
    log.info(`worker ${worker.process.pid} died`);
    const newWorker = createFork();

    log.info(`Worker ${newWorker.process.pid} started`);
  });

  function createFork() {
    let worker = cluster.fork();
    let killTimeout;
    let shutdownTimeout;

    worker.on('listening', (address) => {
      shutdownTimeout = setTimeout(() => {
        log.info('Cleaning up old workers');
        worker.send('shutdown');
        worker.disconnect();
        killTimeout = setTimeout(() => {
          worker.kill();
        }, 90000);
      }, 3600000 + Math.floor((Math.random() * 100000) + 90000));
    });

    worker.on('disconnect', () => {
      clearTimeout(killTimeout);
      clearTimeout(shutdownTimeout);
    });

    return worker;
  }
} else {
  const http = require('http');
  const screenshot = require('electron-screenshot-service');

  const server = http.createServer((req, res) => {
    [] (calling code from different files)
  });
  server.listen(8080, '0.0.0.0', err => {
    log.info('listening on ' + address + ':' + port);

    if (err) {
      log.error(err, err.stack.split('\n'));
      process.exit(1);
    }
  });

  log.info(`Worker ${process.pid} started`);

  process.on('message', (msg) => {
    if (msg === 'shutdown') {
      server.close(() => {
        screenshot.close();
      });
    }
  });
}

On a specific action, the webserver is calling the screenshot command, like this:

const screenshot = require('electron-screenshot-service');
[]
    screenshot({
      url: url,
      partition: 'in-memory', // Disable electron cache
      width: 1024,
      height: 768,
      page: true,
    .then(function (img) {
      callback(true, img.data);
    })
    .catch(function (err) {
      callback(false, 'Failed to create screenshot');
    });
[]

Not working on Windows 8.1

Uncaught exception
Error: connect EADRNOTAVAIL

My index.js
var fs = require('fs');
var screenshot = require('atom-screenshot');

screenshot({
url : 'http://google.de',
width : 1024,
height : 768
})
.then(function(buffer){
fs.writeFile('./out.png', buffer, function(err){
screenshot.close();
});
});

My package.json
{
"name": "atomscreenshot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"atom-screenshot": "^0.4.5"
}
}

Can't install it on windows 10

Log:

npm WARN install:[email protected] [email protected] postinstall: `node install.js`
npm WARN install:[email protected] spawn C:\WINDOWS\system32\cmd.exe ENOENT
npm WARN install:[email protected] [email protected] postinstall: `node install.js`
npm WARN install:[email protected] Exit status -4058
electron-screenshot@ C:\Users\trikadin\Documents\electron-screenshot-service\electron-service\node_modules\electron-screenshot-service\electron-service\node_modules\electron-screenshot-service\electron-service
└── (empty)

electron-screenshot@ C:\Users\trikadin\Documents\electron-screenshot-service\electron-service\node_modules\electron-screenshot-service\electron-service\node_modules\electron-screenshot-service\electron-service
└── (empty)

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--prefix" "./electron-service"
npm ERR! node v5.5.0
npm ERR! npm  v3.3.12

npm ERR! Callback called more than once.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\trikadin\Documents\electron-screenshot-service\electron-service\node_modules\electron-screenshot-service\electron-service\node_modules\electron-screenshot-service\npm-debug.log
npm ERR! code 1
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--prefix" "./electron-service"
npm ERR! node v5.5.0
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `npm install --prefix ./electron-service`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'npm install --prefix ./electron-service'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron-screenshot-service package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm install --prefix ./electron-service
npm ERR! You can get their info via:
npm ERR!     npm owner ls electron-screenshot-service
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\trikadin\Documents\electron-screenshot-service\electron-service\node_modules\electron-screenshot-service\npm-debug.log
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--prefix" "./electron-service"
npm ERR! node v5.5.0
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `npm install --prefix ./electron-service`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'npm install --prefix ./electron-service'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron-screenshot-service package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm install --prefix ./electron-service
npm ERR! You can get their info via:
npm ERR!     npm owner ls electron-screenshot-service
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\trikadin\Documents\electron-screenshot-service\npm-debug.log

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
npm ERR! node v5.5.0
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `npm install --prefix ./electron-service`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'npm install --prefix ./electron-service'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron-screenshot-service package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm install --prefix ./electron-service
npm ERR! You can get their info via:
npm ERR!     npm owner ls electron-screenshot-service
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\trikadin\Documents\electron-screenshot-service\npm-debug.log

Usage example not working 'as is'

I'm launching the usage example and I'm having the following error.

A Javascript error occurred in the main process
Uncaught Exception:
Error: connect EADDRNOTAVAIL 0.0.0.0:52799
at Object.exports._errnoException (util.js:837:11)
at exports._exceptionWithHostPort (util.js:860:20)
at TCPConnectWrap.afterConnect as oncomplete

Doesn't throw an error and it just hangs on Ubuntu 16.04 with NodeJS 6.10.3

First of all, thanks for this useful package.

I have server on DigitalOcean with this following setup:
Ubuntu 16.04
NodeJS 6.10.3

Used the code below:

var fs = require('fs');
var screenshot = require('electron-screenshot-service');

screenshot({
url : 'http://google.de',
width : 1024,
height : 768
})
.then(function(img){
fs.writeFile('./out.png', img.data, function(err){
screenshot.close();
});
});

Unfortunately, when I run this code, it just hangs and doesn't display any errors in the console nor in the debug file for node.js.

electron error while installing

I am quite new to the npm packaging, so this might be something obvious, but when running

npm install electron-screenshot-service #or
sudo npm install -g electron-screenshot-service

or even running root@pc:/root/npm# npm install electron-screenshot-service errored, so it can't be permission, can it?

terminal:

> [email protected] postinstall /root/npm/node_modules/electron
> node install.js

module.js:457
    throw err;
    ^

Error: Cannot find module '/root/npm/node_modules/electron/install.js'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
/root/npm
├─┬ [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ └── [email protected] 
├── [email protected] 
└─┬ [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  └─┬ [email protected] 
    └── [email protected] 

npm WARN enoent ENOENT: no such file or directory, open '/root/npm/package.json'
npm WARN npm No description
npm WARN npm No repository field.
npm WARN npm No README data
npm WARN npm No license field.
npm ERR! Linux 4.4.0-36-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "electron-screenshot-service"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs electron
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls electron
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm/npm-debug.log

log npm-debug.log

It says the error has something to do with electron, but I can run/develop fine for electron.

Thanks for your time!

`page` option not working

Hey hey,

thanks for this. I'd really go for electron for screenshots.

Unfortunately this code here:

#!/usr/bin/env node

var fs         = require('fs');
var screenshot = require('electron-screenshot-service');

screenshot({
  url    : 'http://www.loopline-systems.com/en',
  width  : 1024,
  height : 2000,
  page   : true
})
.then( function( img ){
  fs.writeFileSync('./styleguide.png', img.data );

  screenshot.close();
} )
.catch( function( error ) {
  console.log( error );

  screenshot.close();

  process.exit( 1 );
} );

Does not generate the whole image. page seems to be completely ignored... Any comments on that?

Installed electron-prebuilt version is

Thanks in advance.

Electron error popup if service is not closed immediately after screenshot

Whenever I take a screenshot and not run screenshot.close() afterwards, I will get the following electron error in a popup:

Uncaught Exception:
TypeError: Cannot read property 'id' of null
    at Timeout.makeScreenshot (<PATH>/node_modules/electron-screenshot-service/electron-service/node_modules/electron-screenshot-app/index.js:61:42)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)

Is this expected behaviour? If so the following might be a noob question but here we go:

Do I have to close the service after each screenshot (as this prevents the error from showing)? If so, how do I take another screenshot after closing the service?

screenshot.scale(5)
I'm on OSX 10.11
electron-screenshot-service: 3.1.3

Example hangs when running multiple screen shots

I'm trying to use the multiple.js example file with multiple urls

i.e. i've modified the code to

Promise.all(['http://www.google.de/','http://www.google.no/', 'http://www.google.se/', 'http://www.google.co.uk/'].map(function (url) {

and run

node example/multiple.js

I'm getting intermittent results,

sometimes I get all the pngs produced fine, sometimes it just hangs with no error message.
My network connection is fine.

Any ideas?

OSX 10.11.2.
node v5.2.0

Javascript not executing properly

First off, thank you for creating and maintaining this library. Much appreciated!

I found this library after using nodeshot which I tried on my system and worked. After running this library however I saw that picture rendering didn't seem to work. After some debugging I found out that it was a javascript issue which was the cause of the pictures not loading.

When I use version 2.3.1 everything works as expected, but 3.0.0 and later do not seem to execute javascript properly. I used the following website to test it: https://www.whatismybrowser.com/detect/is-javascript-enabled

Maybe some injected javascript is throwing an error which causes the remaining javascript not to execute? I would love to help, but I'm not sure how to debug the electron launched window.

I'm on OSX 10.11, node v5.2.0

thanks in advance.

Installation error on windows

Is the module suppose to work on windows?
Running npm install electron-screenshot-service on Windows 10 produces the following error:

15231 error code ELIFECYCLE
15232 error [email protected] postinstall: `cd ./electron-service; npm install .`
15232 error Exit status 1
15233 error Failed at the [email protected] postinstall script 'cd ./electron-service; npm install .'.
15233 error Make sure you have the latest version of node.js and npm installed.
15233 error If you do, this is most likely a problem with the electron-screenshot-service package,
15233 error not with npm itself.
15233 error Tell the author that this fails on your system:
15233 error     cd ./electron-service; npm install .

Maybe Windows doesn't like the postinstall script format?

node v6.3.0
npm v3.10.3
Windows 10

PORT issue on windows

on windows, there is an issue when connecting to the sockets.

Uncaught Exception:
Error: connect EADDRNOTAVAIL 0.0.0.0:7601
    at Object.exports._errnoException (util.js:949:11)
    at exports._exceptionWithHostPort (util.js:972:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)

It seems like axon is using 0.0.0.0 as a default ip address, while this might not be wanted.
I think it might be an elegant solution to create an environment variable for HOST:
pull request

when specifying 127.0.0.1 the issue goes away

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.