---
title: "Discussion on \"The Scope Is Cancelled, the Work Isn’t: Four Quiet Escapes from viewModelScope\" | Hashnode"
description: "Discussion on \"The Scope Is Cancelled, the Work Isn’t: Four Quiet Escapes from viewModelScope\". NonCancellable, callbackFlow, GlobalScope, and stateIn(Eagerly) all outlive onCleared(). Four TestScope tests prove it, then fix it."
url: "https://hashnode.com/posts/the-scope-is-cancelled-the-work-isn-t-four-quiet-escapes-from-viewmodelscope/6b0e7366505fdc1a8d925763"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [The Scope Is Cancelled, the Work Isn’t: Four Quiet Escapes from viewModelScope](https://android-expert.hashnode.dev/the-scope-is-cancelled-the-work-isn-t-four-quiet-escapes-from-viewmodelscope?utm_source=hashnode&utm_medium=feed)

NonCancellable, callbackFlow, GlobalScope, and stateIn(Eagerly) all outlive onCleared(). Four TestScope tests prove it, then fix it.

20h ago · 17 min read · android-expert.hashnode.dev  
Read the article

-   [#android-development](https://hashnode.com/tag/android-development)
-   [#kotlin-coroutines](https://hashnode.com/tag/kotlin-coroutines)
-   [#kotlin-flow](https://hashnode.com/tag/kotlin-flow)
-   [#viewmodel](https://hashnode.com/tag/viewmodel)
-   [#memory-leak](https://hashnode.com/tag/memory-leak)

## Written by

[Android Expert](https://hashnode.com/@android-expert)

@android-expert · Chennai, India

  
[View profile](https://hashnode.com/@android-expert)

Android Expert· Kotlin, Jetpack Compose & production pitfalls

Android Engineer &amp; Kotlin Advocate. 🚀 Deep dives into Jetpack Compose, Coroutines, and Clean Architecture. Turning complex code into scalable solutions. 🛠️✨

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
