carcabot / tiktok-signature

Generate tiktok signature token using node
755 stars 286 forks source link

UnhandledPromiseRejectionWarning: Error: Page crashed! #29

Closed robindz closed 4 years ago

robindz commented 4 years ago

Just noticed the local http server logged this error into the console, I'm unsure what caused this as I was not monitoring the system at the time of the error, but it does result in browser.js failing to produce a valid token. The stacktrace, unfortunately in a bad format, below:

image

Is it possible that the js file could require some extra error handling to prevent crashes like this?

If it's of any more help, I tried manually executing browser.js and it returned this error:

image

Line 48 in index.js for me is await this.page.goto("http://tiktok.com:8080/index.html", {

fedeemilo commented 4 years ago

I have the same problem! please help

carcabot commented 4 years ago

@GodsWithin the last image is because server is not running when tried to generate token. This is because of the first error, but I'm not sure what is meaning the first error.

fedeemilo commented 4 years ago

Is there a way to dynamically generate a signature every time I make a query with, for example, these parameters: id = 10346733 & minCursor = 0 & maxCursor = 0 & type = 3 & count = 30

I know that browser.js is used to generate the signature, but how could I execute it inside the server when a query is made?

robindz commented 4 years ago

@carcabot If I recall correctly, this error occured when starting the server.

robindz commented 4 years ago

@fedeemilo Create a new command line process from whatever language you're using with the correct arguments.

zmeeust commented 4 years ago

@carcabot If I recall correctly, this error occured when starting the server.

I have the same issue after starting server. Also TimeoutError after 30 sec. /tiktok/signature $ node server.js (node:83) UnhandledPromiseRejectionWarning: Error: Page crashed! at Page._onTargetCrashed (/tiktok/signature/node_modules/puppeteer/lib/Page.js:213:24) at CDPSession.Page.client.on.event (/tiktok/signature/node_modules/puppeteer/lib/Page.js:122:56) at CDPSession.emit (events.js:182:13) at CDPSession._onMessage (/tiktok/signature/node_modules/puppeteer/lib/Connection.js:200:12) at Connection._onMessage (/tiktok/signature/node_modules/puppeteer/lib/Connection.js:112:17) at WebSocketTransport._ws.addEventListener.event (/tiktok/signature/node_modules/puppeteer/lib/WebSocketTransport.js:44:24) at WebSocket.onMessage (/tiktok/signature/node_modules/ws/lib/event-target.js:120:16) at WebSocket.emit (events.js:182:13) at Receiver.receiverOnMessage (/tiktok/signature/node_modules/ws/lib/websocket.js:789:20) at Receiver.emit (events.js:182:13) (node:83) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:83) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. { TimeoutError: Navigation timeout of 30000 ms exceeded at Promise.then (/tiktok/signature/node_modules/puppeteer/lib/LifecycleWatcher.js:142:21) at process._tickCallback (internal/process/next_tick.js:68:7) -- ASYNC -- at Frame.<anonymous> (/tiktok/signature/node_modules/puppeteer/lib/helper.js:111:15) at Page.goto (/tiktok/signature/node_modules/puppeteer/lib/Page.js:672:49) at Page.<anonymous> (/tiktok/signature/node_modules/puppeteer/lib/helper.js:112:23) at Signer.getTac (/tiktok/signature/index.js:68:21) at process._tickCallback (internal/process/next_tick.js:68:7) name: 'TimeoutError'

robindz commented 4 years ago

@zmeeust Depending on your restart period, you should be fine if you store the previously generated signature in your application. Of course, if the server after a new period fails to restart again it might happen that your signature is now outdated and requires a manual server restart.

zmeeust commented 4 years ago

@GodsWithin but first we need to start the server. I hope author will fix it.

carcabot commented 4 years ago

Hi guys,

I have updated the main repo, please take a look and update your code, I hope this code it's much better than previous and more stable.

There's an integrated http server which let you generate signatures dynamically using one chrome session.

Greetings.

zmeeust commented 4 years ago

@carcabot I`m so sorry, but

Screenshot from 2020-04-16 14-35-52

carcabot commented 4 years ago

On my side server is running without errors.

This is an error related to puppeteer, probably your device is running out of memory.

Try this topic maybe you'll find an answer.

Can you tell me what device you use ? Can you test also on other devices ?

Thanks.

zmeeust commented 4 years ago

@carcabot thank you for your response. I am use it with docker and alpine python 3 image. Than install dependencies: nodejs, npm, chromium, npm i puppeteer puppeteer-extra puppeteer-extra-plugin-stealth. Also i add "executablePath: "/usr/bin/chromium-browser" to "options" in index.js to be able to find chromium inside container. Maybe i miss some needed packages. And i am not so familiar with js.

Update: By your link i see that i need to add some changes in Dockerfile to be able to start Puppeteer correctly. I`ll investigate that topic. Thanks.

zmeeust commented 4 years ago

@carcabot Everything works fine. Problem in Docker environment. I had to add "await this.page.setDefaultNavigationTimeout(0);" to index.js, because of TimeoutError: Navigation timeout of 30000 ms.

And i see now we could not get comments by "https://m.tiktok.com/share/item/comment/list?id=

Thank a lot.

carcabot commented 4 years ago

@zmeeust unfortunately TikTok removed these days comments from their web api. Comments are only available on mobile API now. You can still get trends and other stuff that are available on website.