ClawKit Logo
ClawKitReliability Toolkit

Fix Slack Socket Mode Crash

Known Bug โ€” Build 2026.2.19-2

This crash is a confirmed bug in the Slack plugin's EventEmitter initialization. The fix is to update to the latest version and regenerate your Slack App Token.

The Slack channel crashes immediately on startup with Cannot read properties of undefined (reading 'listeners'). The gateway enters an exponential backoff retry loop but never recovers without a fix.

Next Step

Fix now, then reduce repeat incidents

If this issue keeps coming back, validate your setup in Doctor first, then harden your config.

The Error in Gateway Logs

Cannot read properties of undefined (reading 'listeners')
[slack] channel exited
Retrying in 5000ms...
Retrying in 10000ms...

The crash happens during channel initialization before any messages are processed. The Slack socket connection never completes, and exponential backoff retries all fail the same way.

Fix: Update OpenClaw + Regenerate App Token

Step 1: Update to Latest Version

Update
npm install -g openclaw@latest

Step 2: Regenerate the Slack App-Level Token

Regenerate in Slack Developer Portal

  1. 1. Go to api.slack.com/apps
  2. 2. Select your OpenClaw app
  3. 3. Click Basic Information in the left sidebar
  4. 4. Scroll to App-Level Tokens
  5. 5. Find your token (or create one) with connections:write scope
  6. 6. Click Regenerate (or Generate Token and Scopes)
  7. 7. Copy the new xapp-... token

Step 3: Update Token in OpenClaw Config

Update App Token
openclaw config set channels.slack.appToken "xapp-YOUR-NEW-TOKEN"
openclaw gateway restart

Alternative: Rebuild the Slack App Configuration

If regenerating the token doesn't fix it, try creating a brand new Slack app and configuring it fresh. Some configuration combinations trigger the EventEmitter bug in ways that a token regeneration alone can't fix.

Verify Slack App Setup

Socket Mode is enabled

Slack App โ†’ Settings โ†’ Socket Mode โ†’ Enable Socket Mode

App-Level Token has connections:write

Basic Information โ†’ App-Level Tokens โ†’ Token must include connections:write scope

Bot Token Scopes are correct

OAuth & Permissions โ†’ Bot Token Scopes: chat:write, channels:read, channels:history, app_mentions:read

Event Subscriptions are enabled

Event Subscriptions โ†’ Enable Events โ†’ Subscribe to: message.channels, app_mention

Required Slack Scopes

Bot Token Scopes (xoxb-)

chat:write
channels:read
channels:history
app_mentions:read
im:read
im:history
im:write

App-Level Token Scopes (xapp-)

connections:write

App-Level Token is required for Socket Mode โ€” it's different from the Bot Token.

Slack Won't Send Files (files:write Scope)

Even with files:write scope granted, Slack file uploads may fail silently. This is because the legacy files.upload API was deprecated โ€” OpenClaw needs to use files.uploadV2, which requires the bot to be a member of the target channel.

Diagnosis Steps

  1. 1Verify files:write and files:read scopes are granted in OAuth & Permissions
  2. 2In the target channel, type /invite @YourBot to add the bot
  3. 3Update to the latest OpenClaw which uses files.uploadV2
Update for uploadV2 support
npm install -g openclaw@latest
openclaw gateway restart

Common Pitfall

Having files:write scope is not enough โ€” the bot must also be a member of the channel where files are being uploaded. DMs work automatically, but public/private channels require an explicit /invite.

Still Crashing?

Check the exact crash location in logs:

Debug Logs
openclaw logs --follow | grep -i slack

Run the Doctor

npx clawkit-doctor@latest

Checks channel configuration, token validity, and gateway health.

Did this guide solve your problem?