#21809: fix(slack): prevent native command startup crash on options registration
channel: slack
size: S
Cluster:
Slack Thread Management Fixes
## Problem summary
- Enabling `commands.native: true` for Slack can crash provider startup when Bolt's `app.options()` registration path throws (`Cannot read properties of undefined (reading 'listeners')`).
- Startup aborts before Slack can connect, causing repeated channel restart loops.
## Expected vs actual
- Expected: Slack provider starts and slash commands stay available even if external select option listeners are unavailable.
- Actual: provider crashes during native command registration and never connects.
## Impact
- High impact for Slack users enabling native commands (`commands.native: true`): channel stays down and slash automation is unavailable.
## Reproduction
1. Configure Slack with `commands.native: true`.
2. Start the gateway in an environment where Bolt options registration throws.
3. Observe startup failure: `Cannot read properties of undefined (reading 'listeners')`.
## Issues list
| ID | Issue | Severity | Status |
| --- | --- | --- | --- |
| PR-21809-BUG-01 | #21306 Slack native commands startup crash | High | Fixed |
## Fix approach
- Treat external arg-menu support as best-effort.
- If `app.options` is missing or throws during registration, disable external option menus and fall back to static select/button menu rendering.
- Keep native command routing operational instead of failing provider startup.
- Add regression coverage for options-registration-throws fallback path.
## Tests run
- `pnpm test -- src/slack/monitor/slash.test.ts`
- `pnpm check`
- `pnpm build`
Fixes #21306
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Wrapped `app.options()` registration in a try-catch block to prevent Slack provider startup crashes when external select menu listeners are unavailable. When registration throws, the code now disables external select menus (`supportsExternalArgMenus = false`) and falls back to static select menus, allowing native commands to remain operational.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix correctly implements defensive error handling for a startup crash scenario. The try-catch is narrowly scoped to the registration call, the fallback mechanism already existed in the codebase logic, and the test coverage validates the fallback behavior works as expected.
- No files require special attention
<sub>Last reviewed commit: fdf5a97</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19911: fix(slack): bind `this` context for `app.options()` in slash comman...
by myra-tapcart · 2026-02-18
86.2%
#21721: fix: bind Slack slash options handler context
by AIflow-Labs · 2026-02-20
83.5%
#17879: fix: prevent Slack auth errors from crashing the entire gateway
by zuyan9 · 2026-02-16
77.1%
#21967: Harden Slack allow-from resolution against undefined catch crash
by graysurf · 2026-02-20
75.5%
#21163: Prevent Slack DNS errors from crashing the gateway
by graysurf · 2026-02-19
73.9%
#23787: Handle transient Slack request errors without crashing the gateway
by graysurf · 2026-02-22
73.6%
#22096: fix(slack): traverse .original for Slack SDK errors; pass recipient...
by maiclaw · 2026-02-20
73.5%
#8024: fix(slack): resolve channel names via directory for cross-account m...
by emma-digital-assistant · 2026-02-03
73.5%
#20479: fix(slack): keep replies flowing for oversized file uploads
by olyashok · 2026-02-19
73.1%
#12369: fix: register unhandled rejection handler for Slack monitor
by Yida-Dev · 2026-02-09
72.5%