Skip to content

fix(gateway): offload channel directory session scans off the event loop#60984

Merged
teknium1 merged 2 commits into
mainfrom
salvage/60810-channel-dir-offload
Jul 9, 2026
Merged

fix(gateway): offload channel directory session scans off the event loop#60984
teknium1 merged 2 commits into
mainfrom
salvage/60810-channel-dir-offload

Conversation

@teknium1

@teknium1 teknium1 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Channel directory builds no longer block the gateway event loop. Salvages PR #60810 by @embwl0x (earliest and most complete of three competing fixes; #60840 by @AlexFucuson9 and #60919 by @AIalliAI closed as duplicates with credit).

Root cause: build_channel_directory() is async and runs on the gateway event loop, but _build_discord() (guild/channel cache walk) and _build_from_sessions() (synchronous SQLite SessionDB scans) were called inline — on large session databases this stalls message delivery for every connected platform.

Changes

  • gateway/channel_directory.py: wrap all five blocking builder call sites in asyncio.to_thread — the Discord cache walk, session-based discovery, plugin-platform discovery, and both _build_from_sessions("slack") merges inside _build_slack() (the two sites the duplicate PRs missed).
  • tests/gateway/test_channel_directory.py: thread-identity regression tests asserting the builders never run on the loop thread (+80 LOC).
  • scripts/release.py: AUTHOR_MAP entry for @embwl0x.

Validation

Result
tests/gateway/test_channel_directory.py 43/43 pass

Contributor authorship preserved via cherry-pick; merge with rebase.

Infographic

channel-directory-offload

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter platform/slack Slack app adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 8, 2026
@teknium1 teknium1 force-pushed the salvage/60810-channel-dir-offload branch from 13d0769 to 94e974e Compare July 9, 2026 12:26
@teknium1 teknium1 merged commit daedf4f into main Jul 9, 2026
43 of 54 checks passed
@teknium1 teknium1 deleted the salvage/60810-channel-dir-offload branch July 9, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/discord Discord bot adapter platform/slack Slack app adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants