realcoloride / node_characterai

Unofficial Character AI wrapper for node.
https://beta.character.ai/
341 stars 72 forks source link

Session closed #137

Closed JasonARong closed 7 months ago

JasonARong commented 7 months ago

Hello! When I am deving on localhost, every time when I try to send a chat to the AI after I put my machine to sleep, it returns the following error:Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed. I am wondering if it is just how localhost works. Are there any solutions?

realcoloride commented 7 months ago

Hello, this is likely a problem caused by chromium (puppeteer) to save resources. I assume chromium does not run in the background when your computer is sleeping, atleast on Windows.

image Source: https://stackoverflow.com/questions/76693058/turning-off-chrome-sleep-mode#:~:text=Friends%2C%20hello%2C%20Google%20Chrome%20puts,mode%2C%20JavaScript%20code%20stops%20running.

It is not an issue related to localhost, as your computer can still respond to local network requests (depending on your settings/OS of course), even if the pc is "shut down" (see Wake On Lan).

However, you might want to look out for extensions or startup arguments for chrome, but sadly I am not aware of any. Otherwise, do not put your computer to sleep or host it on a dedicated server.

But for that, it is not a solution related to the package itself, so I will close it. But feel free to re-open an issue if you have problems with the package.

JasonARong commented 7 months ago

Thanks! Really appreciate your help.