slackapi / slackapi/node-slack-sdk

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

Open
#2,167 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triage-skip needs info pkg:socket-mode
Dominant language
TypeScript
Stars
3.4k
Forks
688
Avg merge
15h 31m
Merged PRs (30d)
27

Description

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

https://github.com/slackapi/node-slack-sdk/blob/039bd050cd736d666d063397067cb014adf23711/packages/socket-mode/src/SocketModeClient.ts#L344

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/socket-mode/src/SocketModeClient.ts at the referenced line and trace how messages with an undefined event.payload.event are handled. Check the socket-mode package's existing test coverage for WebSocket messages, then verify that a missing payload no longer causes an unhandled TypeError and is handled gracefully.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.