fix: await send_message chain to eliminate flaky user_message_count test#368
Merged
sudo-tee merged 1 commit intosudo-tee:mainfrom Apr 28, 2026
Merged
Conversation
send_message fired off the .and_then/.catch chain without awaiting it, causing the user_message_count decrement to be deferred via vim.schedule_wrap. The test relied on vim.wait(50ms) polling which was insufficient on macOS CI runners. Await the chain inside send_message (already Promise.async) so the promise reflects the full operation lifecycle, and replace the polling loops in tests with deterministic :wait() calls.
8d50195 to
b561883
Compare
Owner
|
This is a great fix, thanks |
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
.and_then/.catchchain insend_messageso the returned promise reflects the full operation lifecycle, not just the setup phasevim.wait(50ms)polling in tests with deterministic:wait()calls on the promiseProblem
The
increments and decrements user_message_count correctlytest was consistently failing onmacos-latest, v0.11.4CI (example on main).send_messagefired off the.and_then/.catchchain without awaiting it. Sincecreate_messagereturned an already-resolved promise, the.and_thencallback was deferred viavim.schedule_wrap. The test usedvim.wait(50, ...)to poll for the count decrement, which was not reliably sufficient on macOS runners.Fix
send_messageis alreadyPromise.async(runs in a coroutine), so adding:await()at the end of the chain is the correct fix — it makes the function wait for the full send lifecycle before resolving. The tests then use:wait()on the returned promise instead of polling.