peerigon / phridge

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

Cannot read property 'stdin' of null #41

Closed w0rm closed 8 years ago

w0rm commented 8 years ago

Hello! Thanks for this wonderful wrapper that makes interaction with phantom much simpler and straightforward.

I am using phridge to generate png sprite from svg sources. Yesterday I received an issue from someone using my gulp plugin: https://github.com/w0rm/gulp-svgfallback/issues/7 with an error message coming from phridge sources.

I am not able to reproduce this, but, maybe, you have an idea of what can possibly go wrong there.

phridge is used only in the generateSprite function: https://github.com/w0rm/gulp-svgfallback/blob/master/index.js#L104

jhnns commented 8 years ago

Thx for reporting this, I'll take a look :grin:

w0rm commented 8 years ago

@jhnns thanks for helping out!

ChrisZieba commented 8 years ago

@jhnns was there ever a fix for this? I'm seeing this happen quite a bit on our end. Any info you need to help resolve?

TypeError: Cannot read property 'stdin' of null
    at Phantom._write (/var/app/current/node_modules/phridge/lib/Phantom.js:229:43)
    at /var/app/current/node_modules/phridge/lib/Phantom.js:217:14
    at new wrappedPromise (/var/app/current/node_modules/newrelic/lib/instrumentation/core/globals.js:133:18)
    at Phantom._send (/var/app/current/node_modules/phridge/lib/Phantom.js:201:12)
    at Page.run (/var/app/current/node_modules/phridge/lib/Page.js:60:25)
    at Object.server.checkIfPageIsDoneLoading (/var/app/current/node_modules/prerender/lib/server.js:289:24)
    at Timeout._repeat (/var/app/current/node_modules/prerender/lib/server.js:251:19)
    at Timeout.wrapper [as _onTimeout] (timers.js:417:11)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)

I temporarily modified our module to return if not defined

Phantom.prototype._write = function (message) {
    if (!this.childProcess || !this.childProcess.stdin) return;
    this.childProcess.stdin.write(JSON.stringify(message) + os.EOL, "utf8");
};
jhnns commented 8 years ago

We could add this if clause, but that would just obscure the underlying problem. This callback should never been called when childProcess is null so we have to find that cause first.

Can you give some additional information? When exactly does that error happen? Can you reproduce it reliably?

ChrisZieba commented 8 years ago

Havent been able to reproduce since updating prerender. Might have been caused by this: https://github.com/prerender/prerender/issues/342#issuecomment-242588130

jhnns commented 8 years ago

Ok. I'll re-open it when you have more information :)

Kakise commented 6 years ago

I've got the same error on my end quite a bit. I don't know how to solve it.

https://github.com/Kakise/Blog/issues/24

If you check the travis build logs, you'll see that it is a completely random issue.