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

[Bug] Bot Randomly Crashes #371

Open
Tnology opened this issue Nov 10, 2023 · 1 comment
Open

[Bug] Bot Randomly Crashes #371

Tnology opened this issue Nov 10, 2023 · 1 comment
Labels
bug 🐛 Something isn't working

Comments

@Tnology
Copy link

Tnology commented Nov 10, 2023

What's the bug?
My bot, which uses Harmony, will sometimes crash at random with an "Uncaught DiscordAPIError".

How do we reproduce it?
I'm unable to consistently reproduce the error. My bot will randomly crash if I leave it running, and I'm not sure about how it's triggered. The code to my bot is here: https://github.com/Tnology/TnologyDiscordBot

What should have happened?
The bot is supposed to function properly and not crash.

What is actually happening?
While my bot is running, the bot randomly crashes with an error as seen below:

error: Uncaught DiscordAPIError:
GET /guilds/471700758354460672/members/1017989345292058656 returned 404
(10007) Unknown Member
      throw new DiscordAPIError({
            ^
    at BucketHandler.execute (https://raw.githubusercontent.com/harmonyland/harmony/daca400ae9feab19604381abddbdab16aa1ede2b/src/rest/bucket.ts:224:13)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async BucketHandler.push (https://raw.githubusercontent.com/harmonyland/harmony/daca400ae9feab19604381abddbdab16aa1ede2b/src/rest/bucket.ts:55:13)
    at async RESTManager.make (https://raw.githubusercontent.com/harmonyland/harmony/daca400ae9feab19604381abddbdab16aa1ede2b/src/rest/manager.ts:236:12)
    at async RESTManager.get (https://raw.githubusercontent.com/harmonyland/harmony/daca400ae9feab19604381abddbdab16aa1ede2b/src/rest/manager.ts:259:12)
    at async MemberRolesManager._resolveMemberPayload (https://raw.githubusercontent.com/harmonyland/harmony/daca400ae9feab19604381abddbdab16aa1ede2b/src/managers/memberRoles.ts:22:23)
    at async MemberRolesManager.array (https://raw.githubusercontent.com/harmonyland/harmony/daca400ae9feab19604381abddbdab16aa1ede2b/src/managers/memberRoles.ts:50:17)
[root@vps TnologyDiscordBot]# 

The bot fully stops as a result of the crash and needs to be restarted.

What versions you're using?

  • OS: Rocky Linux 8.8, Kernel 4.18.0-477.21.1.el8_8.x86_64
  • Deno: Deno 1.38.0
  • Harmony: Harmony Commit daca400ae9feab

Do you have anything to tell us more about the bug?
I attempted to use an unhandledrejection event handler, but it doesn't really work in my bot's code. Here is the code that I tried with my bot:

// unhandledrejection.js
globalThis.addEventListener("unhandledrejection", (e) => {
  console.log("unhandled rejection at:", e.promise, "reason:", e.reason);
  e.preventDefault();
});

function Foo() {
  this.bar = Promise.reject(new Error("bar not available"));
}

new Foo();
Promise.reject();

Source: Deno Docs, https://deno.com/blog/v1.24#unhandledrejection-event

Instead, here is the output that I get (trying to run on Windows 11, as I am testing from VS Code):

C:\Users\Tyler\Documents\GitHub\TnologyDiscordBot>deno run -A main.ts
error: Uncaught Error: bar not available
    this.bar = Promise.reject(new Error("bar not available"));
                              ^
    at new Foo (file:///C:/Users/Tyler/Documents/GitHub/TnologyDiscordBot/main.ts:718:31)
    at file:///C:/Users/Tyler/Documents/GitHub/TnologyDiscordBot/main.ts:721:3
    at eventLoopTick (ext:core/01_core.js:183:11)

C:\Users\Tyler\Documents\GitHub\TnologyDiscordBot>

It works in the Deno CLI when I just run deno and paste the code there, but not with my bot. I'm not sure why.

@Tnology Tnology added the bug 🐛 Something isn't working label Nov 10, 2023
@arija-ari
Copy link

GET /guilds/471700758354460672/members/1017989345292058656 returned 404
(10007) Unknown Member

tells you it. You are doing something with members and for some reason the member is not found in the guild. Just a guess:

You might do something with your server members after receiving and holding a list of them? What happens if a member leaves your server in the meantime? It might be the culprit. I think you need to refetch your members and validate the member still being in your server.

Just a guess, I'm not really playing with the member API at all, but that's what it reads to me. 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants