lukehorvat/screenshot-tweet

More verbose error reporting?

halfiranian opened this issue · 11 comments

Hi there, big thanks for a really, really useful bit of code. I've had this successfully running in CLI and in a little script I wrote but now it's stopped working on both.

I'm getting "an unexpected error occurred" on the CLI after it tries to grab the screenshot.

I'm guessing this could be either through Twitter's rate limiting or something else going on but no idea how to start debugging it because I'm not getting any pointers.

Any ideas?

Thanks

Hey, I just published a new version that should make the error messages a bit more meaningful. 👍 Let me know if it helps.

Unfortunately Nightmare/Electron can return some ambiguous errors at times, so that may not be enough. If that's the case for you, then I recommend modifying the package's code directly to determine what the problem is. In other words, open /usr/local/lib/node_modules/screenshot-tweet/dist/index.js (or wherever you installed it) and add some console.log statements in the appropriate places to debug it.

Ah brilliant thanks Luke.

Strangely now it says "Error: Tweet does not exist!"

This is what I'm inputting into the CLI which definitely exists:

screenshot-tweet https://twitter.com/cnnbrk/status/1045015100837560321 cnn.jpg

Thanks again,

J

(I'll try tweaking the package's code directly as you suggest)

Hmmm, that's weird. It works for me...

screenshot

Are you running this on a remote server somewhere? Maybe the tweet is not available in that server's location?

No I'm running it locally. And I'm viewing the tweet in my browser. Really strange since it worked before. Will keep digging but struggling a bit!

Okay, if you're running it locally then try changing the new Nightmare() line to new Nightmare({ show: true, openDevTools: true }). This will make the Electron browser actually show what it is doing when it attempts to take the screenshot. While the browser is open, use its DevTools to see if there's a HTML element on the page that matches the selector .tweet[data-tweet-id="1045015100837560321"].

(Prior to doing this, remove the process.exit lines in cli.js so that the Electron browser doesn't automatically close.)

Hi Luke - just checking if I'm installing this with npm is it pulling this version? The code seems a bit different but I'm relatively new to all this.

You can run screenshot-tweet -v to check the version; it should be 1.1.1. If not, you need to run npm install again.

If you're referring to the fact that the code looks different to what's on GitHub, it's because I use a tool called Babel to compile it prior to publishing.

Ok thanks I'm on the right version. I just can't find "new Nightmare()" in the compiled index.js

Thanks again for all this help going above and beyond!

No problem.

I just checked and it looks like the line is actually new _nightmare.default(), so you should do new _nightmare.default({ show: true, openDevTools: true }). My mistake.