[PR #15876] server: cancel pull on client disconnect #77634

Open
opened 2026-05-05 10:18:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15876
Author: @samrusani
Created: 4/29/2026
Status: 🔄 Open

Base: mainHead: codex/cancel-pull-on-client-disconnect


📝 Commits (1)

  • 2480700 server: cancel pull on client disconnect

📊 Changes

3 files changed (+63 additions, -12 deletions)

View changed files

📝 server/download.go (+19 -7)
📝 server/routes.go (+16 -5)
server/routes_stream_test.go (+28 -0)

📄 Description

Fixes #13142.

Summary

  • make /api/pull progress sends respect the request context so a disconnected streaming client does not wedge the pull goroutine
  • publish blob download cancellation state before waiters can attach, so the last waiter can cancel the shared download promptly
  • add a focused test that verifies stream sends return after context cancellation

Duplicate check

Before opening this, I checked the issue discussion and searched existing PRs for #13142, cancel/abort pull, and download context cancellation. I did not find an existing PR for this exact Option A fix.

Testing

  • git diff --cached --check
  • gofmt -w server/download.go server/routes.go server/routes_stream_test.go could not be run locally: gofmt is not installed in this environment
  • go test ./server could not be run locally: go is not installed in this environment

🔄 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/15876 **Author:** [@samrusani](https://github.com/samrusani) **Created:** 4/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/cancel-pull-on-client-disconnect` --- ### 📝 Commits (1) - [`2480700`](https://github.com/ollama/ollama/commit/248070094b4afdaeb6f06442f8dcb5108a72cda0) server: cancel pull on client disconnect ### 📊 Changes **3 files changed** (+63 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `server/download.go` (+19 -7) 📝 `server/routes.go` (+16 -5) ➕ `server/routes_stream_test.go` (+28 -0) </details> ### 📄 Description Fixes #13142. ## Summary - make `/api/pull` progress sends respect the request context so a disconnected streaming client does not wedge the pull goroutine - publish blob download cancellation state before waiters can attach, so the last waiter can cancel the shared download promptly - add a focused test that verifies stream sends return after context cancellation ## Duplicate check Before opening this, I checked the issue discussion and searched existing PRs for #13142, cancel/abort pull, and download context cancellation. I did not find an existing PR for this exact Option A fix. ## Testing - `git diff --cached --check` - `gofmt -w server/download.go server/routes.go server/routes_stream_test.go` could not be run locally: `gofmt` is not installed in this environment - `go test ./server` could not be run locally: `go` is not installed in this environment --- <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-05-05 10:18:28 -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#77634