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

Can't send from IRC to Discord afterwards. #461

Open
DaVinci030 opened this issue Jan 11, 2019 · 14 comments
Open

Can't send from IRC to Discord afterwards. #461

DaVinci030 opened this issue Jan 11, 2019 · 14 comments

Comments

@DaVinci030
Copy link

I've been using this for more than a year. I'm not good at explaining but here's the issue I copied from the command prompt.

(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) UnhandledPromiseRejectionWarning: TypeError: this.client.listenerCou
nt is not a function
at item.request.gen.end (C:\Users\TV-Nihon\AppData\Roaming\npm\node_modules
discord-irc\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.j
s:87:29)
at then (C:\Users\TV-Nihon\AppData\Roaming\npm\node_modules\discord-irc\node
_modules\snekfetch\src\index.js:214:21)
at
at process._tickCallback (internal/process/next_tick.js:189:7)
(node:5220) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). (rejection
id: 2)
(node:5220) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead
(node:5220) DeprecationWarning: Collection#find: pass a function instead<

After the "UnhandledPromiseRejectionWarning" shows up, it cannot send transmission from IRC to Discord from one of the multiple channels (while the rest are working).

Screenshots from Discord: https://i.imgur.com/9N6TX6e.png, IRC: https://i.imgur.com/jfaaVTv.png

Can you fix that issue?

P.S. "DeprecationWarning: Collection#find: pass a function instead" annoys me so can you do something about that?

@stonerl
Copy link

stonerl commented Mar 12, 2019

I do have the exact same problem. Do you need any more debug logging?

@Throne3d
Copy link
Collaborator

This looks like it's coming from within discord.js, an upstream library used by discord-irc. I have no idea what it's trying to do there, though, and the bot uses the latest version.

@stonerl
Copy link

stonerl commented Mar 13, 2019

Thanks for looking into it, let's wait for upstream to fix it. As a workaround, I use a systemd timer to restart discord-irc every hour.

@Kovaelin
Copy link

Kovaelin commented May 31, 2019

Seems similar to #326 and #328. It looks like there was a fix with another project Headline/Discord-IRC-Relay#13

@zertap
Copy link

zertap commented Jun 21, 2019

The error message occurs for me when many lines are sent at once. IRC-> discord cuts off on 5th or so message, iirc.

@Throne3d
Copy link
Collaborator

Throne3d commented Aug 9, 2020

I'll close this issue for now, as I haven't heard anything recent and the above logs look strange (our uses of find are all currently valid?). If you notice any recent connectivity issues, please get back in touch!

@Throne3d Throne3d closed this as completed Aug 9, 2020
@ticpu
Copy link

ticpu commented Aug 12, 2020

Sorry to say, but I'm still getting that and will probably add --unhandled-rejections=strict to the service to see if systemd can just restart it instead of being blind about the bot not working.

Aug 12 18:49:13 masterpi npm[2731]: (node:2731) UnhandledPromiseRejectionWarning: FetchError: request to https://discordapp.com/api/v7/channels/653307272004632623/messages failed, reason: getaddrinfo EAI_AGAIN discordapp.com
Aug 12 18:49:13 masterpi npm[2731]:     at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:107:21)
Aug 12 18:49:13 masterpi npm[2731]:     at runMicrotasks (<anonymous>)
Aug 12 18:49:13 masterpi npm[2731]:     at processTicksAndRejections (internal/process/task_queues.js:93:5)
Aug 12 18:49:13 masterpi npm[2731]: (node:2731) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 32415)

Edit 1: It is very much like #356 too.

Edit 2:
I just wanted to paste my systemd service file in case it might help someone setup a secure instance. RootDirectory obviously has to exist and contain a functional Linux capable of running node/npm for this to work. In my case, it is my actual root BTRFS subvolume. Can't use / there.

[Unit]
Description=Discord to IRC bridge
Wants=network-online.target
After=network-online.target

[Service]
#ExecStart=/usr/bin/npm start -- --config /etc/discord-irc.json
ExecStart=/usr/bin/node --unhandled-rejections=strict dist/index.js --config /etc/discord-irc.json
RootDirectory=/mnt/btrfs/@root
BindReadOnlyPaths=/usr/src/discord-irc:/app
BindReadOnlyPaths=/home/alarm/.config/discord-irc/config.json:/etc/discord-irc.json
BindReadOnlyPaths=/run/systemd/resolve/resolv.conf:/etc/resolv.conf
SystemCallFilter=@system-service
SystemCallFilter=~@chown @resources @setuid setns
PrivateDevices=true
ProtectHome=tmpfs
WorkingDirectory=/app
DynamicUser=true
Restart=always
RestartSec=15
Environment=HOME=/home

[Install]
WantedBy=multi-user.target

@Throne3d
Copy link
Collaborator

Hrrm, that's a shame. Are you testing out the latest alpha version (v2.9.0-alpha)? If not, would you be able to try that out and see if the same issue occurs? This seems to be happening in discord.js, which is a library we rely on, but it's had quite a significant recent update, and I wonder if it might have improved the behavior around this.

@Throne3d Throne3d reopened this Aug 15, 2020
@ticpu
Copy link

ticpu commented Aug 15, 2020

It is running v2.8.1-11-g5af02c1 at the moment, is it considered 2.9 or should I git pull?

@Throne3d
Copy link
Collaborator

Throne3d commented Aug 15, 2020

I can't actually seem to find g5af02c1 in the repo (is that a Git commit?), so I'm not sure if you're on a more recent version than the release, but 2.8.1 was 41f8444, and the main relevant change for 2.9.0-alpha happened in f047ce0 - at the end of the v2.8.1...v2.9.0-alpha comparison. I'd git pull to be safe!

@ticpu
Copy link

ticpu commented Aug 15, 2020

My bad, I should have git log before posting. g5af02c1 = git shorthash when you remove the leading g. Git log shows that this short hash is "Add 2.9.0-alpha to CHANGELOG" 5af02c1

@ticpu
Copy link

ticpu commented Sep 24, 2020

I almost forgot about this ticket and when I checked again, surprise! The service crashed a couple time but systemd restarted it as expected.

With strict mode enabled, here is the log that is spit out before crashing:

Sep 10 12:57:43 masterpi node[27874]: 2020-09-10T16:57:43.620Z info: Connected to Discord
Sep 10 12:57:44 masterpi node[27874]: 2020-09-10T16:57:44.669Z info: Connected to IRC
Sep 10 12:57:44 masterpi node[27874]: 2020-09-10T16:57:44.737Z info: Connected to IRC
Sep 10 12:57:53 masterpi node[27874]: 2020-09-10T16:57:53.724Z info: Connected to Discord
Sep 14 17:17:46 masterpi node[27874]: 2020-09-14T21:17:46.664Z error: Received error event from IRC {
Sep 14 17:17:46 masterpi node[27874]:   prefix: 'wolfe.freenode.net',
Sep 14 17:17:46 masterpi node[27874]:   server: 'wolfe.freenode.net',
Sep 14 17:17:46 masterpi node[27874]:   command: 'err_notregistered',
Sep 14 17:17:46 masterpi node[27874]:   rawCommand: '451',
Sep 14 17:17:46 masterpi node[27874]:   commandType: 'error',
Sep 14 17:17:46 masterpi node[27874]:   args: [ '*', 'You have not registered' ]
Sep 14 17:17:46 masterpi node[27874]: }
Sep 14 17:17:49 masterpi node[27874]: 2020-09-14T21:17:49.855Z info: Connected to IRC
Sep 14 17:17:57 masterpi node[27874]: 2020-09-14T21:17:57.987Z info: Connected to IRC
Sep 14 17:24:42 masterpi node[27874]: 2020-09-14T21:24:42.989Z info: Connected to IRC
Sep 14 20:20:46 masterpi node[27874]: 2020-09-15T00:20:46.050Z error: Received error event from IRC {
Sep 14 20:20:46 masterpi node[27874]:   prefix: 'card.freenode.net',
Sep 14 20:20:46 masterpi node[27874]:   server: 'card.freenode.net',
Sep 14 20:20:46 masterpi node[27874]:   command: 'err_cannotsendtochan',
Sep 14 20:20:46 masterpi node[27874]:   rawCommand: '404',
Sep 14 20:20:46 masterpi node[27874]:   commandType: 'error',
Sep 14 20:20:46 masterpi node[27874]:   args: [ 'TiCPU_', '#btrfs', 'Cannot send to nick/channel' ]
Sep 14 20:20:46 masterpi node[27874]: }
Sep 14 20:32:35 masterpi node[27874]: /app/node_modules/discord.js/src/rest/RequestHandler.js:158
Sep 14 20:32:35 masterpi node[27874]:           new HTTPError(res.statusText, res.constructor.name, res.status, item.request.method, request.path),
Sep 14 20:32:35 masterpi node[27874]:           ^
Sep 14 20:32:35 masterpi node[27874]: Response: Internal Server Error
Sep 14 20:32:35 masterpi node[27874]:     at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:158:11)
Sep 14 20:32:35 masterpi node[27874]:     at runMicrotasks (<anonymous>)
Sep 14 20:32:35 masterpi node[27874]:     at processTicksAndRejections (internal/process/task_queues.js:93:5) {
Sep 14 20:32:35 masterpi node[27874]:   code: 500,
Sep 14 20:32:35 masterpi node[27874]:   method: 'post',
Sep 14 20:32:35 masterpi node[27874]:   path: '/channels/653307177762553881/messages'
Sep 14 20:32:35 masterpi node[27874]: }
Sep 14 20:32:35 masterpi systemd[1]: discord-irc.service: Main process exited, code=exited, status=1/FAILURE
Sep 14 20:32:35 masterpi systemd[1]: discord-irc.service: Failed with result 'exit-code'.
Sep 14 20:32:35 masterpi systemd[1]: discord-irc.service: Consumed 4min 43.594s CPU time.
Sep 14 20:32:45 masterpi systemd[1]: discord-irc.service: Scheduled restart job, restart counter is at 1.
Sep 14 20:32:45 masterpi systemd[1]: Stopped Discord to IRC bridge.
Sep 14 20:32:45 masterpi systemd[1]: discord-irc.service: Consumed 4min 43.594s CPU time.
Sep 14 20:32:45 masterpi systemd[1]: Started Discord to IRC bridge.

@Throne3d
Copy link
Collaborator

Throne3d commented Oct 3, 2020

Based on that log, it looks like something went wrong internally in Discord, since it returned an Internal Server Error?

The upstream discord.js provides a retryLimit option for 500-error requests, which looks targeted at this. I'll try adding a retry limit of 3 (rather than the default of 1), and then cut a beta, to see if that helps out!

Edit: On second thoughts, the significant changes to discord.js seem to be going well (either that or nobody's testing the current version), so I'll just cut a regular release.

Throne3d added a commit that referenced this issue Oct 3, 2020
Intended to avoid issues with 500 errors returned
from Discord, as in #461.
Throne3d added a commit that referenced this issue Oct 3, 2020
Intended to avoid issues with 500 errors returned
from Discord, as in #461.
@ticpu
Copy link

ticpu commented Dec 29, 2020

From my point of view, this issue is fixed, when the retries can't handle it, the only way to fix 500 errors is wait for the platform to heal itself and restart. So, having the service manager handle the restart does it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants