Skip to content

Invalidate client URLSessions on deinit to fix file-descriptor leak - #95

Merged
Lazarus-931 merged 1 commit into
mainfrom
fix/urlsession-fd-leak
Jul 24, 2026
Merged

Invalidate client URLSessions on deinit to fix file-descriptor leak#95
Lazarus-931 merged 1 commit into
mainfrom
fix/urlsession-fd-leak

Conversation

@Lazarus-931

@Lazarus-931 Lazarus-931 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

The chat, image, and metrics clients each create an ephemeral URLSession but never invalidate it, so its underlying sockets/file descriptors are retained until process exit. The metrics client is recreated on server start and polled while the app idles, so descriptors accumulate over a long-running session until the process hits its open-file limit, causing a CoreAnimation "Too many open files" crash seen in #84.

This includes deinit so descriptors are released when the client is deallocated.

The chat, image, and metrics clients each create an ephemeral URLSession but
never invalidate it, so its underlying sockets/file descriptors are retained
until process exit. The metrics client is recreated on server start and polled
while the app idles, so descriptors accumulate over a long-running session
until the process hits its open-file limit — surfacing as a CoreAnimation
"Too many open files" crash. Invalidate each session in deinit so its
descriptors are released when the client is deallocated.

@lucasnewman lucasnewman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch!

@Lazarus-931
Lazarus-931 merged commit a3750f7 into main Jul 24, 2026
2 checks passed
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.

2 participants