peerigon / phridge

A bridge between node and PhantomJS
The Unlicense
519 stars 50 forks source link

after dispose phantom, the other phantom stdout not work #27

Closed sodawy closed 9 years ago

sodawy commented 9 years ago

i need help, friends~

as the code: 1、set phridge.config.stdout to my stream 2、phridge.spawn() to create phantomA and phantomB 3、phantomA.dispose() 4、open a page by phantomB. i am sure that phantom has accessed the local page by log, but the phantom stdout do not through my stream

var phridge = require('phridge');
var through = require('through'); //https://github.com/dominictarr/through

//set stdout to the two-way stream(by through), so i handle the messages from phantom
phridge.config.stdout = through(function(buf){
    console.log(buf.toString());
    this.queue(buf);
}, function(){
    this.queue(null)
});

var phantomA, phantomB;

phridge.spawn()
    .then(function(phantom){
        phantomA = phantom;

        return phridge.spawn();
    })
    .then(function(phantom){
        phantomB = phantom;

        return phantomA.dispose();
    })
    .then(function(){
        var page = phantomB.createPage();
        return page.run(function(resolve){
            var page = this;
            page.open('http://localhost/touch', function(){
                console.log(page.url);                 //not to my std stream
                resolve();
            })
        })
    })
    .then(function(){
        console.log('done');
    });

some advice?? thank you!

jhnns commented 9 years ago

Published with 1.0.8

sodawy commented 9 years ago

it works fine, thank you!