Skip to content

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

@levenleven

Description

@levenleven

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-triage-skipneeds infoAn issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions