Skip to content

fix: await send_message chain to eliminate flaky user_message_count test#368

Merged
sudo-tee merged 1 commit intosudo-tee:mainfrom
jbro:fix/flaky-messaging-test
Apr 28, 2026
Merged

fix: await send_message chain to eliminate flaky user_message_count test#368
sudo-tee merged 1 commit intosudo-tee:mainfrom
jbro:fix/flaky-messaging-test

Conversation

@jbro
Copy link
Copy Markdown
Contributor

@jbro jbro commented Apr 28, 2026

Summary

  • Await the .and_then/.catch chain in send_message so the returned promise reflects the full operation lifecycle, not just the setup phase
  • Replace flaky vim.wait(50ms) polling in tests with deterministic :wait() calls on the promise

Problem

The increments and decrements user_message_count correctly test was consistently failing on macos-latest, v0.11.4 CI (example on main). send_message fired off the .and_then/.catch chain without awaiting it. Since create_message returned an already-resolved promise, the .and_then callback was deferred via vim.schedule_wrap. The test used vim.wait(50, ...) to poll for the count decrement, which was not reliably sufficient on macOS runners.

Fix

send_message is already Promise.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.

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.
@jbro jbro force-pushed the fix/flaky-messaging-test branch from 8d50195 to b561883 Compare April 28, 2026 07:49
@sudo-tee
Copy link
Copy Markdown
Owner

This is a great fix, thanks

@sudo-tee sudo-tee merged commit d515b84 into sudo-tee:main Apr 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants