[PR #14725] [CLOSED] fix: potential file descriptor leak in ListHandler #40681

Closed
opened 2026-04-23 01:32:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14725
Author: @sushilibdev
Created: 3/9/2026
Status: Closed

Base: mainHead: fix-listhandler-resource-leak


📄 Description

While investigating issue #14723, I noticed that ListHandler in server/routes.go uses defer f.Close() inside a loop. This can lead to a "too many open files" error or hanging when a user has many models, as the files aren't closed until the entire handler returns.

This PR wraps the manifest opening logic in a closure to ensure file descriptors are closed immediately after each iteration.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14725 **Author:** [@sushilibdev](https://github.com/sushilibdev) **Created:** 3/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-listhandler-resource-leak` --- ### 📄 Description While investigating issue #14723, I noticed that ListHandler in server/routes.go uses defer f.Close() inside a loop. This can lead to a "too many open files" error or hanging when a user has many models, as the files aren't closed until the entire handler returns. This PR wraps the manifest opening logic in a closure to ensure file descriptors are closed immediately after each iteration. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 01:32:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#40681