Repository navigation
fix(discord): preserve component waiter message ownership - #117492
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 4:53 PM ET / 20:53 UTC. ClawSweeper reviewWhat this changesThe PR makes Discord component-wait replacement return the displaced caller’s original Merge readinessKeep this PR open for normal maintainer merge review. Current Priority: P2 Review scores
Verification
How this fits togetherDiscord interaction replies create a local flowchart LR
A[Discord interaction reply] --> B[Create caller message]
B --> C[Component wait registry]
C --> D{Wait key already exists?}
D -->|Yes| E[Settle displaced caller]
D -->|No| F[Store active waiter]
G[Discord component interaction] --> C
C --> H[Return result with owner message]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +38. Total +38 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the registry-owner fix with its identity regression test after refreshing the branch/check state against current main; keep replacement timeout semantics and ordinary interaction resolution unchanged. Do we have a high-confidence way to reproduce the issue? Yes. A high-confidence source reproduction creates two distinct Is this the best way to solve the issue? Yes. The registry owns both the displaced resolver and its original message, and using the stored message aligns replacement settlement with the existing normal-resolution path without changing Discord transport or public configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 77796591370d. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
Co-authored-by: IWhatsskill <[email protected]>
[AI-assisted]
What Problem This Solves
When Discord starts a second component wait for the same message and channel, the component registry intentionally replaces the first waiter. The displaced promise currently receives the second call's Message object instead of the Message instance that originally created that wait.
Failure mode
The replacement branch resolves the stored waiter with its timeout-shaped result, but closes over the new method argument for the message field. That crosses ownership between two distinct callers even though the registry already stores the original Message beside the resolver and timer.
Why This Change Was Made
Resolve a replaced waiter with the Message instance stored in its own registry entry. The newly registered waiter remains active and continues to resolve through the normal component interaction path.
Root Cause
The replacement path used the incoming
messageparameter rather thanexisting.messagefrom the waiter being displaced.Layer ownership
replyAndWaitForComponentsupplies the caller-owned Message,ComponentRegistryowns waiter identity and replacement, and interaction dispatch owns later resolution. The fix stays in the registry owner layer without changing Discord transport, interaction payloads, component parsing, or presentation.User Impact
Each caller now receives the same Message instance that created its wait, including when a later wait replaces it. The replaced waiter still ends with
success: falseandreason: timed out, while the replacement waiter still resolves normally from a component interaction.Evidence
At exact head
ba23fcf7dd412a4e67603a19c4304cdfd35b8d78, 36 focused and adjacent Discord tests passed, Extension source and test typechecks passed, scoped formatting/lint checks were clean, and a real registry run preserved both distinct Message owners across replacement and normal resolution.Inspect exact-head proof ledger
Provenance
b83a966c056288adaef187e3e5826188d9f67724ba23fcf7dd412a4e67603a19c4304cdfd35b8d78Direct behavior
Discord component waiter ownership command
Sanitized exact-head production output
Automated verification
Discord registry and owner chain
pnpm exec vitest run extensions/discord/src/internal/client.test.ts extensions/discord/src/internal/interaction-dispatch.test.ts extensions/discord/src/internal/interactions.test.ts --reporter=dotpnpm exec vitest run extensions/discord/src/internal/client.test.ts extensions/discord/src/internal/interaction-dispatch.test.ts extensions/discord/src/internal/interactions.test.ts --reporter=dot— [TEST] 36/36 tests passed across 3 test files with 0 failures. Proves replacement preserves both caller Message identities and adjacent interaction routing remains compatible. Preserves wildcard and custom-id resolution, interaction dispatch, timer caps, and reply-and-wait behavior.Extension source type boundary
pnpm tsgo:extensions— [TYPECHECK] completed with exit code 0. Proves the registry source change satisfies the Extension TypeScript contract. Preserves the existing component result and Message API surface.Extension test type boundary
pnpm tsgo:extensions:test— [TYPECHECK] completed with exit code 0. Proves the identity regression test satisfies the Extension test TypeScript contract. Preserves the existing Vitest typing boundary.Static verification
pnpm exec oxlint extensions/discord/src/internal/component-registry.ts extensions/discord/src/internal/client.test.tspnpm exec oxlint extensions/discord/src/internal/component-registry.ts extensions/discord/src/internal/client.test.ts— [LINT] reported 0 warnings and 0 errors. Proves the changed source and regression test satisfy scoped lint rules. Preserves the repository lint boundary.pnpm exec oxfmt --check extensions/discord/src/internal/component-registry.ts extensions/discord/src/internal/client.test.tspnpm exec oxfmt --check extensions/discord/src/internal/component-registry.ts extensions/discord/src/internal/client.test.ts— [STATIC] reported both files correctly formatted. Proves the changed files match repository formatting. Preserves the bounded two-file diff.git diff --check origin/main...HEAD— [STATIC] completed with exit code 0 and no output. Proves the exact-head patch is whitespace-clean. Preserves the bounded two-file diff.Preserved boundaries
success: falseandreason: timed out; only its Message owner is corrected.Proof gap
Focused registry and adjacent owner-chain tests, both Extension typechecks, scoped static checks, and a real exact-head ComponentRegistry plus Message proof were run. A credentialed live Discord interaction, the full repository test suite, and GitHub CI were not run locally; no live Discord API, repository-wide, or CI result is claimed.
Artifacts