Skip to content

fix(slack): bind this context for app.options() in slash command arg menus#19911

Open
myra-tapcart wants to merge 1 commit intoopenclaw:mainfrom
myra-tapcart:fix/slack-options-this-binding
Open

fix(slack): bind this context for app.options() in slash command arg menus#19911
myra-tapcart wants to merge 1 commit intoopenclaw:mainfrom
myra-tapcart:fix/slack-options-this-binding

Conversation

@myra-tapcart
Copy link

@myra-tapcart myra-tapcart commented Feb 18, 2026

Problem

Since v2026.2.17, the Slack channel provider crashes immediately on startup with:

[default] channel exited: Cannot read properties of undefined (reading 'listeners')

The provider enters a 1/10 → 10/10 crash loop and never recovers. Slack is completely non-functional.

Root Cause

registerSlackMonitorSlashCommandsregisterArgOptions() destructures ctx.app.options into a local variable:

const optionsHandler = (ctx.app as unknown as { options?: ... }).options;
//                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                      detached from `this` — classic JS footgun
optionsHandler(SLACK_COMMAND_ARG_ACTION_ID, ...);
//             `this` is `undefined` inside Bolt's App.options()

Bolt's App.options() pushes to this.listeners, but this is undefined because the method was called without its receiver.

Other Bolt methods in the same file (ctx.app.action(), ctx.app.command(), ctx.app.view()) are called directly on the app instance and work fine. Only options was destructured.

Fix

-    ).options;
+    ).options?.bind(ctx.app);

One-line fix. Preserves this binding. The optional chain (?.) keeps the existing guard for environments where options may not exist.

Stack Trace

TypeError: Cannot read properties of undefined (reading 'listeners')
    at options (App.ts:849:10)
    at registerArgOptions (subagent-registry-DN6TUJw4.js:48854:3)
    at registerSlackMonitorSlashCommands (subagent-registry-DN6TUJw4.js:48881:2)
    at monitorSlackProvider (subagent-registry-DN6TUJw4.js:49075:2)

Verification

Patched the bundled dist on a live 2026.2.17 instance. Before: crash loop. After: slack socket mode connected — full inbound/outbound working.

Affected Versions

  • Broken: v2026.2.17
  • Working: v2026.2.15

Fixes #19788
Ref: #8404

Greptile Summary

One-line fix for a critical crash-loop in the Slack channel provider introduced in v2026.2.17. The App.options() method from @slack/bolt was destructured into a local variable, detaching it from its this context. Since Bolt's App.options() internally accesses this.listeners, calling the detached method throws Cannot read properties of undefined (reading 'listeners'), crashing the provider on startup.

  • Adds .bind(ctx.app) when extracting options from the Bolt app instance, preserving the method's this context
  • The ?. optional chain is retained so environments where options doesn't exist continue to work via the existing typeof optionsHandler !== "function" guard
  • Other Bolt methods (ctx.app.command(), ctx.app.action()) are called directly on the instance and were unaffected

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-understood one-line fix for a critical crash-loop regression.
  • The fix is a single-line change that correctly addresses a classic JS this-binding issue. The root cause and solution are clear, the author verified it on a live instance, and the change has no side effects on surrounding code. No new logic or risk is introduced.
  • No files require special attention.

Last reviewed commit: cf31361

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

…arg menus

The `registerArgOptions` helper in `registerSlackMonitorSlashCommands`
destructures `ctx.app.options` into a local variable, which detaches the
`this` binding from the Bolt `App` instance. When the detached function
is invoked, `this` is `undefined`, causing:

  TypeError: Cannot read properties of undefined (reading 'listeners')

This crashes the entire Slack channel provider on startup, entering a
retry loop that never recovers.

Fix: add `.bind(ctx.app)` to preserve the `this` context, consistent
with how other Bolt methods (`ctx.app.action()`, `ctx.app.command()`,
`ctx.app.view()`) are called directly on the app instance elsewhere in
the same file.

Fixes openclaw#19788
@vibecodooor
Copy link

Confirmed on Nimbus (macOS, OpenClaw 2026.2.17): this exact failure signature is still reproducible pre-fix and matches the detached this analysis.

Observed in gateway.err.log today (2026-02-18):

  • 88x [slack] [default] channel exited: Cannot read properties of undefined (reading 'listeners')
  • repeated restart-loop / health-monitor limit hits afterwards.

I also validated locally that current Slack test coverage passes without exercising the this-binding failure mode, so a small regression test would help prevent reintroduction (e.g. mock app.options that relies on instance state and assert registration path keeps receiver binding).

lucasmpramos added a commit to butley/openclaw that referenced this pull request Feb 18, 2026
)

Fixes crash-loop: Cannot read properties of undefined (reading 'listeners')
Upstream PR openclaw#19911 still open — applying locally until merged.

Co-authored-by: Bob
@josephsimony
Copy link

The current version of Opanclaw crashes with Slack. Please add this fix asap.

@Jronk
Copy link

Jronk commented Feb 19, 2026

I tested this and this fix resolves the reported issue 👍

@EricNetsch
Copy link

This needs to be merged in soon. Still broken on the newest version 2026.2.21-2

@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack size: XS stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Slack channel crashes on startup with 'Cannot read properties of undefined (reading listeners)' in v2026.2.17

5 participants