GeorgeCiesinski / poke-guesser-bot

Discord bot that lets you guess pokemon
MIT License
0 stars 3 forks source link

/reveal results in a crash and restart #108

Closed GeorgeCiesinski closed 11 months ago

GeorgeCiesinski commented 1 year ago

Describe the bug

Running /reveal results in

poke-bot is thinking...

and spins continuously. It doesn't fail until a very long time passes, but it outputs error into console:

poke-guesser-bot       | /usr/src/app/reveal.js:20
poke-guesser-bot       |                     let lowercaseName = encounter[i].name.toLowerCase();
poke-guesser-bot       |                                                           ^
poke-guesser-bot       | 
poke-guesser-bot       | TypeError: Cannot read properties of undefined (reading 'toLowerCase')
poke-guesser-bot       |     at Commands.reveal (/usr/src/app/reveal.js:20:59)
poke-guesser-bot       |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
poke-guesser-bot       | 
poke-guesser-bot       | Node.js v19.7.0
poke-guesser-bot exited with code 1
poke-guesser-bot       | 
poke-guesser-bot       | > poke-guesser-bot@1.0.0 start
poke-guesser-bot       | > node index.js
poke-guesser-bot       | 
poke-guesser-bot       | Logged in as poke-bot#3409!

To Reproduce

Steps to reproduce the behavior:

  1. Start poke-bot
  2. Run /explore to generate pokemon
  3. Run /reveal to result in error

Expected behavior

/reveal is supposed to output the pokemon

Desktop (fill in or erase if not applicable):

Possible solutions

The cause of the issue is unknown. It is possible poke-api is providing a different object than what it used to show. Another possible place to look is the below documentation:

https://sequelize.org/docs/v6/core-concepts/getters-setters-virtuals/#getters

https://sequelize.org/docs/v6/core-concepts/model-querying-finders/

Wissididom commented 1 year ago

Should be fixed by #103 because I've written To make it work, I had to fix #108 as well into the description of that PR. Needs to be tested, tho, to be sure.

GeorgeCiesinski commented 1 year ago

Tested but still doesn't seem to be working. But as you know, I still have issues loading up the lightning rounds commands.

When I try to /reveal, It says Pokebot is Thinking for a very long time. It will probably fail like before.

I do not know if this is also just a local issue, so are you able to test the latest develop branch to make sure?

Wissididom commented 1 year ago

I just tested it with docker-compose, and it worked without any problem. See below: Screenshot from 2023-09-30 18-33-07

git status says:

On branch develop
Your branch is up to date with 'origin/develop'.

nothing to commit, working tree clean

git pull says:

Already up to date.

git log's latest commit is:

commit a70bf8c040d00ccf907a250e3ac31c015f036530 (HEAD -> develop, origin/develop)
Merge: f70a049 9c9abcf
Author: George Ciesinski <george.ciesin@gmail.com>
Date:   Fri Sep 29 21:58:53 2023 -0400

    Merge pull request #103 from Wissididom/lightning-rounds

Only thing I noticed was that on first run of the docker-compose the database was slower than the bot so the bot connected to the database before it was even ready to accept connections.

GeorgeCiesinski commented 1 year ago

I tested again:

Testing

/explore

poke-guesser-bot       | > poke-guesser-bot@1.0.0 start
poke-guesser-bot       | > node index.js
poke-guesser-bot       | 
poke-guesser-bot       | Logged in as poke-bot#3409!
poke-guesser-bot       | Generating a new Pokemon
poke-guesser-bot       | (sequelize) Warning: Model "encounter" is declaring public class fields for attribute(s): "name", "language".
poke-guesser-bot       | These class fields are shadowing Sequelize's attribute getters & setters.
poke-guesser-bot       | See https://sequelize.org/main/manual/model-basics.html#caveat-with-public-class-fields
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: カラカラ, Language: ja-Hrkt
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: Karakara, Language: roomaji
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: 탕구리, Language: ko
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: 卡拉卡拉, Language: zh-Hant
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: Osselait, Language: fr
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: Tragosso, Language: de
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: Cubone, Language: es
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: Cubone, Language: it
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: Cubone, Language: en
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: カラカラ, Language: ja
poke-guesser-bot       | Guild: 850098788487659581, Channel: 850098788487659584, Name: 卡拉卡拉, Language: zh-Hans
poke-guesser-bot       | https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/104.png
poke-guesser-bot       | https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/104.png
poke-guesser-bot       | (node:19) ExperimentalWarning: buffer.File is an experimental feature and might change at any time
poke-guesser-bot       | (Use `node --trace-warnings ...` to show where the warning was created)

/reveal

poke-guesser-bot       | isMod: true
poke-guesser-bot       | /usr/src/app/reveal.js:20
poke-guesser-bot       |                     let lowercaseName = encounter[i].name.toLowerCase();
poke-guesser-bot       |                                                           ^
poke-guesser-bot       | 
poke-guesser-bot       | TypeError: Cannot read properties of undefined (reading 'toLowerCase')
poke-guesser-bot       |     at Commands.reveal (/usr/src/app/reveal.js:20:59)
poke-guesser-bot       |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
poke-guesser-bot       | 
poke-guesser-bot       | Node.js v19.7.0
poke-guesser-bot       | npm notice 
poke-guesser-bot       | npm notice New major version of npm available! 9.5.0 -> 10.1.0
poke-guesser-bot       | npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.1.0>
poke-guesser-bot       | npm notice Run `npm install -g npm@10.1.0` to update!
poke-guesser-bot       | npm notice 
poke-guesser-bot exited with code 1
poke-guesser-bot       | 
poke-guesser-bot       | > poke-guesser-bot@1.0.0 start
poke-guesser-bot       | > node index.js
poke-guesser-bot       | 
poke-guesser-bot       | Logged in as poke-bot#3409!

Results in:

poke-bot is thinking...

A few seconds later, it outputs:

poke-guesser-postgres  | 2023-09-30 17:05:55.813 UTC [26] LOG:  checkpoint starting: time
poke-guesser-postgres  | 2023-09-30 17:05:57.275 UTC [26] LOG:  checkpoint complete: wrote 17 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=1.444 s, sync=0.007 s, total=1.463 s; sync files=12, longest=0.004 s, average=0.001 s; distance=60 kB, estimate=60 kB

So it looks like a crash.

Branch & Commit

georgeciesinski@Georges-MacBook-Air poke-guesser-bot % git log
commit a70bf8c040d00ccf907a250e3ac31c015f036530 (HEAD -> develop, origin/develop)

So I'm on the same commit. This is really strange because I am running Docker Compose, so I thought that the container would work the same on both of our machines. For some reason on mine I am consistently getting this error.

GeorgeCiesinski commented 1 year ago

I have not tried making code changes yet. I think that we are getting very inconsistent behaviour on your setup and on my setup, so I think this is more important to understand why it is happening before we attempt to resolve this with code changes.

Wissididom commented 1 year ago

Only thing I noticed is that you seem to be using Node.js v19.7.0, while my run used Node.js 20.3.1. According to the Dockerfile I see the image node:20.3-bookworm-slim being used. But that shouldn't be a problem...

GeorgeCiesinski commented 1 year ago

Yeah I agree, I will see if I can find out why this is failing. If I do figure it out I'll update this issue and start the change.

Wissididom commented 11 months ago

Seems to be fixed now