← Back to PRs

#21809: fix(slack): prevent native command startup crash on options registration

by graysurf open 2026-02-20 12:06 View on GitHub →
channel: slack size: S
## 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