Skip to content

Fix Zipline leak after RealTreehouseApp.close call (#2897)#2902

Open
adevone wants to merge 4 commits intocashapp:trunkfrom
adevone:fix_zipline_leak
Open

Fix Zipline leak after RealTreehouseApp.close call (#2897)#2902
adevone wants to merge 4 commits intocashapp:trunkfrom
adevone:fix_zipline_leak

Conversation

@adevone
Copy link

@adevone adevone commented Mar 11, 2026

Fixes Zipline leak on RealTreehouseApp closure (#2897).

Cause of the leak

RealTreehouseApp.close indirectly schedules a resource unloading coroutine on dispatchers.zipline (RealTreehouseApp.stop -> CodeHost.stop -> CodeSession.stop). It starts working because of CoroutineStart.ATOMIC strategy but then crashes in ZiplineScope.close.

This exception could be seen by adding a breakpoint to CodeSession.handleUncaughtException:

java.lang.IllegalStateException: Zipline closed
	at app.cash.zipline.Zipline$endpoint$1.call(Zipline.kt:64)
	at app.cash.zipline.internal.bridge.OutboundCallHandler.callInternal$zipline_release(OutboundCallHandler.kt:116)
	at app.cash.zipline.internal.bridge.OutboundCallHandler.call(OutboundCallHandler.kt:75)
	at app.cash.redwood.treehouse.AppLifecycle$Companion$Adapter$GeneratedOutboundService.close(AppLifecycle.kt:26)
	at app.cash.zipline.ZiplineScope.close(ZiplineScope.kt:93)
	at app.cash.redwood.treehouse.ZiplineCodeSession.ziplineStop(ZiplineCodeSession.kt:73)
	at app.cash.redwood.treehouse.CodeSession$stop$1.invokeSuspend(CodeSession.kt:85)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
  	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651)
  	at java.lang.Thread.run(Thread.java:1119)

  • [+] CHANGELOG.md's "Unreleased" section has been updated, if applicable.

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.

1 participant