Skip to content

TypeError: Cannot read properties of undefined (reading 'type') at SocketModeClient.onWebSocketMessage #2167

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

Open
1 of 7 tasks
levenleven opened this issue Mar 6, 2025 · 8 comments
Labels
needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info

Comments

@levenleven
Copy link
Contributor

Sometimes we get an error due to event.payload.event being undefined

this.emit(event.payload.event.type, {

TypeError: Cannot read properties of undefined (reading 'type')
    at SocketModeClient.onWebSocketMessage (/app/node_modules/@slack/socket-mode/dist/SocketModeClient.js:620:43)
    at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (node:events:514:28)
    at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1070:20)
    at Receiver.emit (node:events:514:28)
    at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:517:14)
    at Receiver.getData (/app/node_modules/ws/lib/receiver.js:435:17)
    at Receiver.startLoop (/app/node_modules/ws/lib/receiver.js:143:22)
    at Receiver._write (/app/node_modules/ws/lib/receiver.js:78:10)
    at writeOrBuffer (node:internal/streams/writable:447:12)
    at _write (node:internal/streams/writable:389:10)
    at Receiver.Writable.write (node:internal/streams/writable:393:10)
    at TLSSocket.socketOnData (/app/node_modules/ws/lib/websocket.js:1164:35)
    at TLSSocket.emit (node:events:514:28)

Packages:

Select all that apply:

  • @slack/web-api
  • @slack/rtm-api
  • @slack/webhooks
  • @slack/oauth
  • @slack/socket-mode
  • @slack/types
  • I don't know

Reproducible in:

The Slack SDK version

"@slack/socket-mode": "1.3.6"

Node.js runtime version

v20.9.0

OS info

#141~20.04.1-Ubuntu SMP Thu Jan 16 18:38:51 UTC 2025

Steps to reproduce:

N/A

Expected result:

Missing payload handled gracefully

Actual result:

Unhandled error

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@misscoded misscoded added needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info and removed untriaged labels Mar 6, 2025
@misscoded
Copy link
Contributor

HI @levenleven! Thanks for bringing this to our attention. Unfortunately, we'll need more information in order to begin to debug and remedy what is going on here. If you're able to provide which event(s) that this error is occurring for, that'd be a great start.

@levenleven
Copy link
Contributor Author

@misscoded thanks for looking into this. We subscribe to message events using bolt sdk (e.g. app.message(...)).

@misscoded
Copy link
Contributor

Are message events the only events that your app listens for/subscribes to then? On your end and with your own logs, are you able to narrow down which specific message event type is causing the issue?

@levenleven
Copy link
Contributor Author

Sorry, missed we also have app.action subscription. So only these two, message and action.

This is not reproducible (at least now), we've got ~ 20 such errors between Mar 5, 2025 10:40:00 PM UTC and Mar 6, 2025 10:51:30 PM UTC

On your end and with your own logs, are you able to narrow down which specific message event type is causing the issue

No, as this is happening not in application but in framework code.

@misscoded
Copy link
Contributor

No worries! If you provide us your app ID, we might be able to look into the logs and figure out what the event in question is.

@levenleven
Copy link
Contributor Author

Thanks! App id is A02V1ADGH5F

@levenleven
Copy link
Contributor Author

Few other occasions

  • Mar 12, 2025 9:42:02 PM UTC - Mar 12, 2025 9:49:31 PM UTC
  • Mar 15, 2025 9:48:01 PM UTC - Mar 15, 2025 9:50:30 PM UTC
  • Mar 17, 2025 9:30:01 PM UTC - Mar 17, 2025 9:36:31 PM UTC

@levenleven
Copy link
Contributor Author

@misscoded Is there anything else I can do to help with the investigation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info
Projects
None yet
Development

No branches or pull requests

2 participants