Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix memory leak in Flet web apps#6089

Merged
FeodorFitsner merged 2 commits intomainfrom
web-memory-leak
Jan 29, 2026
Merged

Fix memory leak in Flet web apps#6089
FeodorFitsner merged 2 commits intomainfrom
web-memory-leak

Conversation

@FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Jan 29, 2026

Summary by Sourcery

Prevent background update scheduler tasks from leaking and adjust web app configuration defaults.

Bug Fixes:

  • Ensure the session updates scheduler runs as a single tracked asyncio task that is cancelled when the session closes, avoiding orphaned tasks and memory leaks.
  • Handle cancellation cleanly in the updates scheduler loop to prevent spurious errors on shutdown.

Enhancements:

  • Promote garbage-collection log messages for sessions and FletApp instances from debug to info for better observability in production.

Deployment:

  • Update example Fly.io app configurations to use FLET_FORCE_WEB_SERVER instead of FLET_FORCE_WEB_VIEW in the environment.

Replaces the FLET_FORCE_WEB_VIEW environment variable with FLET_FORCE_WEB_SERVER in multiple example app and tutorial fly.toml files to reflect updated configuration requirements.
Changed session and FletApp garbage collection logs from debug to info level. Enhanced Session class to properly manage and cancel the updates scheduler task on close, preventing orphaned tasks and improving resource cleanup. Added error handling for task cancellation in the updates scheduler.
@cloudflare-workers-and-pages
Copy link

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9c5381a
Status: ✅  Deploy successful!
Preview URL: https://fb6dce0d.flet-examples.pages.dev
Branch Preview URL: https://web-memory-leak.flet-examples.pages.dev

View logs

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9c5381a
Status: ✅  Deploy successful!
Preview URL: https://11e617b8.flet-docs.pages.dev
Branch Preview URL: https://web-memory-leak.flet-docs.pages.dev

View logs

@FeodorFitsner FeodorFitsner merged commit 87bee30 into main Jan 29, 2026
43 of 70 checks passed
@FeodorFitsner FeodorFitsner deleted the web-memory-leak branch January 29, 2026 19:32
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