Skip to content

Convert Room DAO methods to suspend functions#4102

Merged
jamesarich merged 2 commits into
meshtastic:mainfrom
romansl:romansl-suspend-dao
Dec 31, 2025
Merged

Convert Room DAO methods to suspend functions#4102
jamesarich merged 2 commits into
meshtastic:mainfrom
romansl:romansl-suspend-dao

Conversation

@romansl

@romansl romansl commented Dec 31, 2025

Copy link
Copy Markdown
Contributor

Motivation

This PR converts all non-suspend Room DAO methods to suspend functions, following Android best practices for
database operations. This change aligns with modern coroutine-based architecture and ensures all database
operations are performed off the main thread.

Changes

Updated the following DAOs to use suspend modifier on all methods that:

  • Perform database writes (Insert, Update, Delete, Upsert)
  • Execute queries that return data synchronously
  • Are not already marked as suspend
  • Do not return Flow (which are inherently asynchronous)

Benefits

  1. Thread Safety: Ensures all database operations run on background threads, preventing ANR (Application Not
    Responding) errors
  2. Consistency: All DAO methods now follow the same pattern - either suspend for one-time operations or Flow for
    observable streams
  3. Better Error Handling: Suspend functions integrate better with coroutine error handling and cancellation
  4. Future-Proof: Aligns with Room's recommended patterns and latest best practices

@CLAassistant

CLAassistant commented Dec 31, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jamesarich

Copy link
Copy Markdown
Collaborator

oop looks like this needs a spotless and detekt pass

@jamesarich jamesarich added the enhancement New feature or request label Dec 31, 2025
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich enabled auto-merge December 31, 2025 13:17
@codecov

codecov Bot commented Dec 31, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (21ec78d) to head (64df3ce).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #4102   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          2       2           
  Lines         19      19           
  Branches       7       7           
=====================================
  Misses        19      19           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamesarich jamesarich added this pull request to the merge queue Dec 31, 2025
Merged via the queue into meshtastic:main with commit 8de3806 Dec 31, 2025
6 checks passed
@romansl romansl deleted the romansl-suspend-dao branch January 2, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants