Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

346
Views
phantomjs crea dentro de express El enrutador no se ejecuta

Tengo un servidor con rutas construidas con express.Router . Una de las rutas usa phantom.create() dentro. No puedo ingresar a la función de create , nunca se ejecuta (o lo hace pero sin ningún efecto). Ejecuto este script por 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 });

El servidor registra esto:

 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 - -

Cuando ejecuto el mismo código en una sesión de nodo en vivo ( $ node ), todo funciona bien. ¿Alguna idea de cuál es el problema aquí? Estuve investigando en la fuente create() , pero no pude encontrar ningún rastro allí:/

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

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Solo probé su código con el último Phantom (4.0.1), por lo que no sé si se aplica a la versión que está usando, pero v4 arroja un error con respecto a los argumentos que no se pasan correctamente (deberían ser pasado como una matriz).

Prueba esto:

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

0

Debe agregar una captura al final de su creación para eliminar UnhandledPromiseRejectionWarning.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!