Fix order of message events #4037
Open
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.
Related GitHub Issue
Closes: #4034
Description
Both
Task.addToClineMessages
andTask.updateClineMessage
are async functions.However, when
addToClineMessages
is called, it is awaited,and when
updateClineMessage
is called, it is not awaited.This can result in reordering the execution of these functions,
and thus reordering the
this.emit("message", ...)
calls (and also messages sent to webview probably).The solution is to await on
updateClineMessage
. It should not introduce much performance penalty, as it only sends message to webview and emits an event (addToClineMessages
does much more and it is awaited).Test Procedure
Subscribe to
message
event, run a task and watch the order of message events.The procedure must be run multiple times — not always the events are emitted in wrong order.
However, probably as the change is very small and obvious, it does not need additional testing.
Type of Change
src
or test files.Pre-Submission Checklist
npm run lint
)¹.console.log
) has been removed.npm test
).main
branch.npm run changeset
if this PR includes user-facing changes or dependency updates.²¹ Getting
Invalid option '--ext' - perhaps you meant '-c'?
from eslint.² Getting
Missing script: changeset
Screenshots / Videos
Documentation Updates
Does this PR necessitate updates to user-facing documentation?
Additional Notes
Get in Touch
Discord handle: wkordalski
Important
Fixes message event order by awaiting
updateClineMessage()
inTask.ts
to ensure correct event emission sequence.updateClineMessage()
inTask.ts
to ensure correct order ofmessage
events.ask()
,say()
, and other methods whereupdateClineMessage()
is called.updateClineMessage()
now awaited inask()
,say()
, and 2 other places inTask.ts
.message
events are emitted in wrong order #4034 related to message event order.This description was created by
for ede7cc7. You can customize this summary. It will automatically update as commits are pushed.