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 when activity.type is undefined #920

Open
tinaxd opened this issue Jul 6, 2024 · 0 comments
Open

Crash when activity.type is undefined #920

tinaxd opened this issue Jul 6, 2024 · 0 comments

Comments

@tinaxd
Copy link

tinaxd commented Jul 6, 2024

Hello,

The bridge sometimes crashes with the following error:

yarn run v1.22.22
$ node ./build/src/discordas.js

/home/matrix-discord-bridge/matrix-appservice-discord/src/presencehandler.ts:122
            const type = activity.type[0] + activity.type.substring(1).toLowerCase(); // STREAMING -> Streaming;
                                      ^
TypeError: Cannot read properties of undefined (reading '0')
    at PresenceHandler.getUserPresence (/home/matrix-discord-bridge/matrix-appservice-discord/src/presencehandler.ts:122:39)
    at PresenceHandler.<anonymous> (/home/matrix-discord-bridge/matrix-appservice-discord/src/presencehandler.ts:98:29)
    at Generator.next (<anonymous>)
    at /home/matrix-discord-bridge/matrix-appservice-discord/build/src/presencehandler.js:23:71
    at new Promise (<anonymous>)
    at __awaiter (/home/matrix-discord-bridge/matrix-appservice-discord/build/src/presencehandler.js:19:12)
    at PresenceHandler.ProcessUser (/home/matrix-discord-bridge/matrix-appservice-discord/build/src/presencehandler.js:91:16)
    at PresenceHandler.<anonymous> (/home/matrix-discord-bridge/matrix-appservice-discord/src/presencehandler.ts:106:43)    at Generator.next (<anonymous>)
    at /home/matrix-discord-bridge/matrix-appservice-discord/build/src/presencehandler.js:23:71
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

When this crash occurs, the bridge crashes immediately after rebooting. However, after some time and several reboots, the crash does not reoccur.

To investigate the cause of this error, I added console.log(presence) to presencehandler.ts:120 and got the following output:

Presence {
  userID: '***',
  ~~~
  activities: [
    Activity {
      name: 'Hang Status',
      type: undefined,
      url: null,
      details: null,
      state: 'chilling',
      applicationID: null,
      timestamps: null,
      party: null,
      assets: null,
      syncID: undefined,
      flags: [ActivityFlags],
      emoji: null,
      createdTimestamp: 1720266148832
    }
  ],
  clientStatus: { desktop: 'online' }
}

It seems that this occurs when someone joins a voice channel with a Hang Status set.

I hope this helps!

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

No branches or pull requests

1 participant