Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

344
Vistas
phantomjs create inside express Router does not execute

I have a server with routes built with express.Router. One of the routes uses phantom.create() inside. I can't get inside the create function, it never executes (or it does but without any effect). I run this script by node ./path/to/script :

var express = require("express");
var router  = express.Router();

router.post("/my/path", function(req, res) {
  console.log('req.body.myUrl', req.body.myUrl); // this works

  var phantom = require('phantom');
  phantom.create('--debug=true', '--web-security=false', function(ph) {
    // this never happens:
    console.log('phantom');
    return res.status(200).send({ message: "asdasd" });
  });

  console.log('mamma mia') // this works
});

The server logs this:

req.body.myUrl http://myUrl
mamma mia
# and after a few minutes this:
POST /myUrl - - ms - -
# and then the entire cycle repeats infinitely automatically:
req.body.myUrl http://myUrl
mamma mia
POST /myUrl - - ms - -

When I run the same code in a live node session ($ node), everything works just fine. Any idea what's the issue here? I've was digging in the create() source, but couldn't find any trail there :/

node v6.2.0, express 4.1.0, phantomjs 2.1.1, macOS Sierra 10.12.4,

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I've only tested your code with the latest Phantom (4.0.1), so I don't know if it applies to the version you're using, but v4 throws an error regarding the arguments not being passed correctly (they should be passed as an array).

Try this:

phantom.create([ '--debug=true', '--web-security=false' ], ...);
about 4 years ago · Santiago Trujillo Denunciar

0

You need to add a catch at the end of your create to remove the UnhandledPromiseRejectionWarning.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda