Skip to content

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

Closed

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.

Activity

  1. added
    needs infoAn issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info
    and removed on Mar 6, 2025
  2. misscoded commented on Mar 6, 2025

    @misscoded
    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.

  3. levenleven commented on Mar 7, 2025

    @levenleven
    ContributorAuthor

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

  4. misscoded commented on Mar 7, 2025

    @misscoded
    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?

  5. levenleven commented on Mar 9, 2025

    @levenleven
    ContributorAuthor

    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.

  6. misscoded commented on Mar 13, 2025

    @misscoded
    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.

  7. levenleven commented on Mar 17, 2025

    @levenleven
    ContributorAuthor

    Thanks! App id is A02V1ADGH5F

  8. levenleven commented on Mar 18, 2025

    @levenleven
    ContributorAuthor

    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
  9. levenleven commented on Apr 3, 2025

    @levenleven
    ContributorAuthor

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

  10. github-actions commented on May 5, 2025

    @github-actions
  11. levenleven commented on May 5, 2025

    @levenleven
    ContributorAuthor

    Last seen on Apr 16, so maybe fixed on server side, or we just didn't receive some specific event type that causes this.

  12. 5 remaining items

  13. levenleven commented on Jul 28, 2025

    @levenleven
    ContributorAuthor

    keep

  14. zimeg commented on Jul 29, 2025

    @zimeg
    Member

    Hey @levenleven! 👋 I'm catching up on this thread now and noticed @slack/socket-moode@1.3.6 is used when this error is found.

    The latest release right now is @slack/socket-mode@2.0.4 and I'm wondering if updating to this version resolves this? 🤖

  15. levenleven commented on Aug 5, 2025

    @levenleven
    ContributorAuthor

    Hey @zimeg, looks like the same error after upgrade to "@slack/socket-mode": "2.0.4"

    TypeError: Cannot read properties of undefined (reading 'type')
        at SocketModeClient.<anonymous> (/app/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js:302:47)
        at Generator.next (<anonymous>:null:null)
        at /app/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js:41:71
        at new Promise (<anonymous>:null:null)
        at __awaiter (/app/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js:37:12)
        at SocketModeClient.onWebSocketMessage (/app/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js:263:16)
        at SocketModeClient.emit (/app/node_modules/eventemitter3/index.js:182:35)
        at WebSocket.<anonymous> (/app/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js:87:33)
        at WebSocket.emit (node:events:524:28)
        at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1220:20)
        at Receiver.emit (node:events:524:28)
        at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:596:14)
        at Receiver.getData (/app/node_modules/ws/lib/receiver.js:496:10)
        at Receiver.startLoop (/app/node_modules/ws/lib/receiver.js:167:16)
        at Receiver._write (/app/node_modules/ws/lib/receiver.js:94:10)
        at writeOrBuffer (node:internal/streams/writable:572:12)
        at _write (node:internal/streams/writable:501:10)
        at Receiver.Writable.write (node:internal/streams/writable:510:10)
        at TLSSocket.socketOnData (/app/node_modules/ws/lib/websocket.js:1355:35)
        at TLSSocket.emit (node:events:524:28)
        at addChunk (node:internal/streams/readable:561:12)
        at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
        at TLSSocket.Readable.push (node:internal/streams/readable:392:5)
        at TLSWrap.onStreamRead (node:internal/stream_base_commons:191:23)
        at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17)
    

    if (event.type === 'events_api') {
    this.emit(event.payload.event.type, {

    So event.payload.event here is undefined.

  16. radiantspace commented on Oct 20, 2026

    @radiantspace

    We managed to grab the payload for this error. It's rate limiting event, that SDK doesn't handle:

    {"token":"mytoken","api_app_id":"A02V1ADGH5F","minute_rate_limited":1792487520,"type":"app_rate_limited","team_id":"T01234567"},"type":"events_api","accepts_response_payload":false,"retry_attempt":0,"retry_reason":""}"}

  17. radiantspace commented on Oct 20, 2026

    @radiantspace

    @misscoded @zimeg hey, hope the payload helps to fix the problem ^. That is still reproducible in v3.1.0.

  18. mwbrooks commented on Oct 28, 2026

    @mwbrooks
    Member

    👋 Thanks @levenleven for sticking with this one, and @radiantspace for capturing the payload! It was the app_rate_limited event, which arrives without an inner event. #2754 fixes the crash and will be out in the next @slack/socket-mode release, so I'm going to close this issue.

  19. added this to the socket-mode@next milestone on Oct 28, 2026
  20. added
    bugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented
    and removed
    needs infoAn issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info
    on Oct 28, 2026
  21. self-assigned this
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

auto-triage-skipbugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documentedpkg:socket-modeapplies to `@slack/socket-mode`

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions