Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRASH ON $start A (Raspian) #39

Closed
ava-cassiopeia opened this issue Jun 19, 2020 · 16 comments
Closed

CRASH ON $start A (Raspian) #39

ava-cassiopeia opened this issue Jun 19, 2020 · 16 comments
Assignees
Labels
crash setup-issue Issue setting up the bot
Milestone

Comments

@ava-cassiopeia
Copy link
Owner

Direct copy of #34 comment


Experiencing same issue. dfrotz is installed normally, can be used to play the game from any location.
Bot works until starting a game and entering a command, crashes with the same "throw er, unhandled error event".

Running Raspbian (Debian variant). All packages reinstalled and updated with npm wherever possible.

Capture

2020-06-18T15_37_36_232Z-debug.log

@ava-cassiopeia
Copy link
Owner Author

The error doesn't seem to be coming directly from my code, which makes me suspect that one of the deps has an update that is causing this, or I'm incorrectly calling one of the deps and its triggering this. If providing your package.lock.json wouldn't reveal too much about your system, that could be greatly useful, otherwise I'll attempt to repro by installing the bot from latest.

@KawaiiFiveO
Copy link

This contains the file generated by npm upon install.

package-lock.zip

@ava-cassiopeia
Copy link
Owner Author

ava-cassiopeia commented Jun 21, 2020

@KawaiiFiveO Since you've got the bot installed locally, can you do the following:

  1. npm i --save discord.io (from the bot directory)
  2. Verify that the version of Discord.io is 2.4.0 in your package lock after doing step 1
  3. Run the bot and see if it works

I have discord.io pinned at a specific release because of previous bugs with it, and this looks like its the same category. Pinning to latest (ie. what the above does) seems to fix locally for me. Please let me know if that works for you.

If that doesn't work, I'll considering switching the codebase over to discord.js instead of discord.io. I've been using discord.js for new projects lately and it has been a lot more stable.

@ava-cassiopeia ava-cassiopeia added the setup-issue Issue setting up the bot label Jun 22, 2020
@KawaiiFiveO
Copy link

NPM seems to be very confused on which version to install.
On the initial install of the bot, it installs the latest commit of the gateway-v6 branch.
If run using --save discord.io, it installs version 2.5.3 according to the package lock and the bot crashes upon startup.
If run using --save discord.io@2.4.0, it installs 2.4.0 and the bot also crashes upon startup.

@ava-cassiopeia
Copy link
Owner Author

That's very strange, especially given that 2.5.3 isn't a valid version according to the releases page for that code.

On the readme for discord.io, it does say that you can get true latest by installing izy521/discord.io instead of discord.io. Perhaps that's worth a shot? Not sure if that will play nicely with the require() imports I have in the code though.

Really, though, it seems like the right strategy—as I mentioned before—is to just switch from discord.io to discord.js. I use the .js one in other projects and it works fine. I've created #41 and will try to set aside some time sooner rather than later (this weekend, or hopefully earlier) to take a look and start migrating code. Updates on that will be posted to said bug.

Sorry for the inconvenience, I'm hopeful that this migration will solve your issue.

@ava-cassiopeia
Copy link
Owner Author

I've now fully migrated the bot to the new framework, discord.js.

@KawaiiFiveO could you please install the latest version of the bot (0.14.0) and try again?

@KawaiiFiveO
Copy link

KawaiiFiveO commented Jun 26, 2020

log

I reinstalled the bot and when running it I got this error instead. It seems very similar to the previous one.

@ava-cassiopeia
Copy link
Owner Author

Indeed it does, that's disappointing. Out of curiosity, what version of node are you running?

@KawaiiFiveO
Copy link

Originally I was using latest stable (12.18.1). I just tried updating to current (14.4.0) and now the problem is different.
Instead of crashing upon being given a game command, the bot now does nothing at all. There is no output to either the console or server.

I reinstalled the bot using the npm method instead of manually and the problem still occurred.

@ava-cassiopeia
Copy link
Owner Author

That's strange, I'm not sure what to make of that, especially if your logs have nothing.

Well, if you can revert back to Node 12.18.1, there's one more thing I can think of that might yield additional information: have you tried different games?

@ava-cassiopeia
Copy link
Owner Author

Also, when you ran the games using dfrotz, did you specify the -p flag? If not, could you, and see if that has a meaningful difference?

@ava-cassiopeia
Copy link
Owner Author

Also also (sorry stream of consciousness as I flip through the code), can you double-check that the game file is in the right place as specified in the config.json?

@KawaiiFiveO
Copy link

KawaiiFiveO commented Jun 29, 2020

I got the bot to work. Apparently the error thrown will occur whenever the location of the game file is invalid. I tried several methods to direct the program to the game file before finding the one that worked (place the game in the same directory and just entering the name of the file). Thank you for helping.

More questions:
Is it possible to add multiple games to the config?
Is there a way to kill the bot when it's running in the background? It seems to spawn multiple processes (two node processes and an sh process) and trying to kill it causes the terminal to hang completely. There also isn't a way to kill it via Discord.

@ava-cassiopeia
Copy link
Owner Author

Hooray! I'm glad you've got it working now. That being said, I think this probably brings up a point that maybe I should, in the actual code, double-check the file paths are valid, so I can give a better error than this barely-meaningful error. I've created #43 to address this.

To answer your questions:

Is it possible to add multiple games to the config?

Totally! The games component of the config accepts an array of game objects, for example:

{
    "api": {
        "discord": {
            "token": "[bot token goes here]"
        }
    },
    "games": [
        {
            "name": "exampleName",
            "prettyName": "Example Name",
            "path": "/tmp/foobar.z5"
        },
        {
            "name": "secondGame",
            "prettyName": "Second Game",
            "path": "/tmp/secondGame.z5"
        },
    ],
    "settings": {
        "commandPrefix": "$",
        "commentPrefix": "//"
    }
}

Is there a way to kill the bot when it's running in the background?

Strange, the bot is specifically built to clean itself up when someone tries to kill it (code). I've tested killing the bot before and it seems to clean up the child process correctly. Perhaps the way you are killing it doesn't trigger Node's process.on("exit", ...? How are you killing it, just with [ctrl]-[c]?

There also isn't a way to kill it via Discord.

True, that might be a good feature to add. #44 opened.

@KawaiiFiveO
Copy link

I have the bot running as a background process using npm run start > /dev/null &.
When run this way, ps will list 3 different bot processes, two called "node" and one called "sh".
I attempted to close all of them via different methods (kill, pkill, killall) etc but these would all cause the terminal to either hang completely or become very buggy, unable to display input text unless cleared with reset. However I did find a working solution by asking fkill to kill the node processes instead of using the built-in tools, so this is basically a non-issue now.

@ava-cassiopeia
Copy link
Owner Author

ava-cassiopeia commented Jul 2, 2020

Fair enough, I'll still probably add the feature (since it's pretty easy to do so) at some point. In the meantime, I'm going to close this bug in favor of the followup bugs I created. Feel free to reopen it if you have any other questions or problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash setup-issue Issue setting up the bot
Projects
None yet
Development

No branches or pull requests

2 participants