Skip to content

Leaked viewModelScope coroutines in EpubReaderViewModelTest and ReaderViewModelTest (same root cause as #553, unfixed by #554) #559

Open

Description

@github-actions

Summary

feature/reader/src/test/kotlin/xyz/libravault/feature/reader/epub/EpubReaderViewModelTest.kt and feature/reader/src/test/kotlin/xyz/libravault/feature/reader/ReaderViewModelTest.kt both have the exact same anti-pattern that #553 diagnosed and PR #554 just fixed only for MarkdownReaderViewModelTest: their @AfterEach tearDown() calls Dispatchers.resetMain() but never cancels the viewModelScope of any ViewModel the test created (viewModel() factory just does EpubReaderViewModel(...) / ReaderViewModel(...) directly, with no ViewModelStore to route through).

Both files create ViewModels dozens of times per class (EpubReaderViewModelTest ~10 call sites, ReaderViewModelTest ~50+), so the same class of leaked-coroutine flakiness #553 described is live in both.

Evidence (verified, not assumed)

Found while principal-reviewing PR #554 (which itself only fixes MarkdownReaderViewModelTest). PR #554's own Unit & Integration Tests (JVM) CI run hit exactly this failure mode, just manifesting differently than #553's symptom:

Suggested fix

Apply the same ViewModelStore pattern PR #554 used for MarkdownReaderViewModelTest to EpubReaderViewModelTest and ReaderViewModelTest: route each test's viewModel() factory through a androidx.lifecycle.ViewModelStore field and call viewModelStore.clear() in @AfterEach, before Dispatchers.resetMain().

Impact

Same as #553: low severity on its own, but a real, reproducible, silent source of background-thread noise (and potential future UncaughtExceptionsBeforeTest flakes on unrelated tests) in CI runs touching feature:reader. Filed per the principal-review agent's mandate to give CONFIRMED findings a permanent record (see PR #554 review comment) — this doesn't block #554 itself, which is narrowly and correctly scoped to the class #553 actually named, exactly as #553 didn't block PR #541 when it was found the same way.

Activity

  1. added
    bug
    on Aug 24, 2026
  2. libravault-xyz commented on Aug 26, 2026

    @libravault-xyz
    Collaborator

    Automated pipeline health check: This issue (filed by github-actions[bot], CONTRIBUTOR association) has received zero dev-agent.yml runs and zero explanatory comment of any kind since it was filed.

    Same author-association trust-gate-skip signature already tracked on #469/#475/#479/#388/#408/#433/#437/#441/#544/#558/#582 — but unlike that earlier batch, this issue never got even the explain-trust-gate-skip job's own skip-reason comment, consistent with the regression confirmed on #437/#441 (that job's gh issue comment step has no actions/checkout/--repo, so it fails before posting: fatal: not a git repository).

    Not self-healing: no status label to toggle, and .github/workflows/dev-agent.yml is a sensitive path this routine won't edit.

    This now makes at least 13 open issues sitting with zero pipeline engagement: #469, #475, #479, #487, #504, #523, #534, #556, #557, #559, #561, #581, #589, #611, #626, #639. A tracked issue for the underlying explain-trust-gate-skip checkout/--repo bug has been recommended across at least two prior automated runs (2026-08-23 on #469, 2026-08-24 on #437/#441) but doesn't appear to have been filed yet.

    Action needed: someone with write access can workflow_dispatch triage this issue manually, and/or fix explain-trust-gate-skip's gh issue comment step (add actions/checkout or --repo ${{ github.repository }}) so future instances self-report instead of going silent.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions