fix(mattermost): anchor slash command state to globalThis to fix dual-instance 503s#69038
fix(mattermost): anchor slash command state to globalThis to fix dual-instance 503s#69038hieptuanle wants to merge 1 commit into
Conversation
…fix dual-instance bug Route registration (jiti) and monitor activation (native ESM) load slash-state.ts through different module loaders, creating two separate accountStates Maps. The monitor populates one copy while the HTTP handler reads the other (always empty), causing 503 responses for all slash command callbacks. Anchor accountStates to globalThis via Symbol.for() so both module instances share the same Map. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a dual-instance 503 regression in the Mattermost slash command flow by anchoring the shared Confidence Score: 5/5Safe to merge — minimal, well-scoped change with a clear rationale and a passing test suite. The fix is technically correct: Symbol.for() guarantees the same Symbol across module instances, and the ??= initializer ensures only one Map is ever created on globalThis. No logic changes elsewhere, no new surface area introduced, and all 319 extension tests pass. No files require special attention. Reviews (1): Last reviewed commit: "fix(mattermost): anchor slash command ac..." | Re-trigger Greptile |
|
Please merge |
|
Please please merge |
|
Any updates on this? |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. This PR is a duplicate implementation candidate for the Mattermost native slash-command 503 regression already tracked by open PR #68089 and bug #68113. Current main still has the old dynamic loader plus module-local state, so the bug is not implemented-on-main; cleanup should consolidate review on the earlier, root-cause PR or an equivalent maintainer-owned fix. Best possible solution: Close this duplicate PR and consolidate maintainer review on #68089, or land an equivalent root-cause fix that makes route registration and monitor activation share one Mattermost slash-state module instance. Keep #68113 open until the selected fix merges and ships. What I checked:
So I’m closing this here and keeping the remaining discussion on the canonical linked item. Codex review notes: model gpt-5.5, reasoning high; reviewed against 7a23b2d945cc. |
Summary
Fixes #68113
accountStatesinslash-state.tswas a plain module-levelMapthat got instantiated twice — once by jiti (route registration path vialoadBundledEntryExportSync) and once by native ESM (monitor/activation path via dynamicimport()).accountStatestoglobalThisviaSymbol.for()so both module loader instances share the same Map.Test plan
pnpm test:extension mattermost— all 319 tests passpnpm check— all type, lint, import-cycle checks passpnpm build— clean build, no warnings🤖 Generated with Claude Code