Conversation
Greptile SummaryThis PR makes Discord typing state race-safe by registering per-channel state before asynchronous startup and using object identity to invalidate superseded work.
Confidence Score: 5/5The PR appears safe to merge, with the changed lifecycle preventing orphan typing refresh intervals across the covered races. State is registered before asynchronous Discord requests, checked after each await, and invalidated by stop, replacement, or close before an interval can be installed; the added tests exercise the principal stop and repeated-start races.
|
| Filename | Overview |
|---|---|
| src/discord/connector.ts | Replaces late interval-only tracking with eagerly registered identity-token state, invalidating asynchronous startup across stop, replacement, and shutdown. |
| src/discord/connector.typing.test.ts | Adds focused fake-timer tests showing that stop-during-fetch installs no refresher and repeated starts retain only the newest interval. |
Sequence Diagram
sequenceDiagram
participant Caller
participant Connector
participant Discord
Caller->>Connector: startTyping(channelId)
Connector->>Connector: replace state token
Connector->>Discord: fetch channel
alt state was stopped or superseded
Connector-->>Caller: return without interval
else state remains current
Connector->>Discord: sendTyping()
alt state still current
Connector->>Connector: install refresh interval
else stopped or superseded
Connector-->>Caller: return without interval
end
end
Caller->>Connector: stopTyping(channelId)
Connector->>Connector: clear interval and delete state
Reviews (1): Last reviewed commit: "fix(discord): make typing lifecycle race..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
The refresh interval was stored only after both channel fetch and initial sendTyping completed. A fast activation could stop typing during either await, see no tracked interval, and return; the older start then installed an interval that nothing could stop. Repeated starts could also overwrite the map entry while leaving the prior interval alive.
Verification
Baseline tooling note
npm run build still reports the three existing GenerationConfig type errors in src/llm/membrane/adapter.ts on main. ESLint 9 also has no eslint.config file in the repository. Neither area is changed here.