Skip to content

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Sep 16, 2025

This refactors the watch(), onChange() and AttachmentTest implementations to improve the reliability of the CI.

First, both watch() and onChange() were implemented as a channelFlow this is a somewhat problematic builder, since (quoting the docs):

A channel with the default buffer size is used.

This means that when we call send(), it doesn't necessarily wait for the downstream consumer to process that event, leading to the query potentially running more often than necessary (the behavior we want is to internally buffer upstream changes while a downstream consumer is busy, and then once it handled the previous event we'd re-run the query if there were any changes in the meantime).
I've refactored the implementation to use a regular flow, ensuring that we won't start running a second query until results of the first one are handled. I've also simplified the implementation to reuse more logic between watch and onChange.

Additionally, this updates some attachment tests:

  • The testSkipFailedDownload test asserts a visible transition from QUEUED_DOWNLOAD to ARCHIVED. Depending on how often the SELECT * FROM attachments flow emits items though, it's possible that the QUEUED_DOWNLOAD state is not observable. This updates the test to reflect that.
  • Because the actual attachment sync and the observed SELECT * FROM atttachments flow are decoupled and asynchronous, it's possible that a write to the todos table schedules a query that, at the time it runs, sees a different write. This has been causing a few failures as well, a distinctUntilChanged() deflakes those tests.
  • I also noticed some failures related to waitFor timing out, so this adds more logs around that and replaces the waitFor calls in attachment tests.

@simolus3 simolus3 force-pushed the attachment-test-reliability branch from 5e31992 to 49edfb1 Compare September 16, 2025 14:48
@simolus3 simolus3 marked this pull request as ready for review September 16, 2025 19:17
@simolus3 simolus3 changed the title Debugging CI failures Make CI more reliable Sep 16, 2025
Copy link
Contributor

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must have taken sine effort to find and debug. Thanks for this! Looks good to me.

@simolus3 simolus3 merged commit e7d0f0f into main Sep 17, 2025
5 checks passed
@simolus3 simolus3 deleted the attachment-test-reliability branch September 17, 2025 14:00
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