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

Bot throws error after running it for a period of time #180

Closed
zhiyan114 opened this issue Jul 4, 2023 · 5 comments · Fixed by #181
Closed

Bot throws error after running it for a period of time #180

zhiyan114 opened this issue Jul 4, 2023 · 5 comments · Fixed by #181
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zhiyan114
Copy link
Collaborator

zhiyan114 commented Jul 4, 2023

Problem

After running a bot for a period of time, the bot throws the following errors:

TypeError: Cannot read properties of undefined (reading 'config')
    at Timeout.setStatus [as _onTimeout] (F:\Ticket-Bot\dist\events\ready.js:163:25)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)
❌  WebSocket Error: Error: read ECONNRESET
❌  WebSocket Error: 1006
✅  Connected to WebSocket server.
TypeError: this.telemetry is not a function
    at WebSocketClient.<anonymous> (F:\Ticket-Bot\dist\events\ready.js:217:18)
    at WebSocketClient.emit (node:events:513:28)
    at WebSocketClient.succeedHandshake (F:\Ticket-Bot\node_modules\websocket\lib\WebSocketClient.js:348:10)
    at WebSocketClient.validateHandshake (F:\Ticket-Bot\node_modules\websocket\lib\WebSocketClient.js:332:10)
    at ClientRequest.handleRequestUpgrade (F:\Ticket-Bot\node_modules\websocket\lib\WebSocketClient.js:261:14)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketOnData (node:_http_client:582:11)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)

It seems like the telemetry issue happens after the websocket errors.

Solution

[Unknown] - In Progress

@zhiyan114 zhiyan114 added the bug Something isn't working label Jul 4, 2023
@zhiyan114 zhiyan114 added this to the 3.1.0 milestone Jul 4, 2023
@zhiyan114 zhiyan114 self-assigned this Jul 4, 2023
@Sayrix
Copy link
Owner

Sayrix commented Jul 4, 2023

You should try catch the websocket function

@zhiyan114
Copy link
Collaborator Author

zhiyan114 commented Jul 4, 2023

I feel like there's something to do with how setInterval and setTimeout are handled in NodeJS since both issue happens when the code is being call by either one of it.
I'll go head and play around with it to confirm that statement, and if it's true then it's NodeJS engine bug.

We could try/catch, but that's gonna produce a more buggy code. Prob best to try and figure out why it's causing it first so that in the future, when writing a similar code, we know how to avoid it.

@Sayrix
Copy link
Owner

Sayrix commented Jul 4, 2023

Yean but that's strange because in JS when the websocket have an error he just try to reconnect to it not throwing error

@zhiyan114
Copy link
Collaborator Author

zhiyan114 commented Jul 4, 2023

This is def a strange bug. We can confirm three things here:

  1. config is not undefined because it's being read when the bot is first turned on
  2. this.telemetry is always a function because nowhere in any of the codes changed that (and it's a horrible practice anyway)
  3. Error seems to only happen if the method is called inside the two time-based callback functions.

@zhiyan114
Copy link
Collaborator Author

Yup confirmed it. I'll push out a fix.

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

Successfully merging a pull request may close this issue.

2 participants