[PR #3118] [CLOSED] fix(serve): a cached image whose .sve was deleted is encoded again; a 500 instead of a dropped connection #4462

Closed
opened 2026-11-07 15:36:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3118
Author: @kai-chop
Created: 10/19/2026
Status: ❌ Closed

Base: main ← Head: fix-vision-cache-500


📝 Commits (1)

  • a66e941 fix(serve): a cached image whose .sve was deleted is encoded again; a 500 instead of a dropped connection

📊 Changes

3 files changed (+142 additions, -1 deletions)

View changed files

📝 serve/server.py (+16 -1)
➕ serve/test_internal_error_500.py (+71 -0)
➕ serve/test_vision_cache_missing.py (+55 -0)

📄 Description

Title

Issue: none filed

Summary

A cached image whose .sve file has been deleted from the encoder's temp directory (%TEMP%\strata-vision-*; something cleaned it while the server ran) makes every request that carries that picture end with a dropped connection and no answer. Clients that resend the whole history (opencode, Claude Code) then fail every later request of the conversation; opencode reports only ECONNRESET and retries forever.

Two causes, both still on main:

  1. Vision.encode treats a key in self.cache as a hit without checking that its file still exists, so the engine is handed a missing file.
  2. The resulting FileNotFoundError is an OSError, and _post's except OSError treats every OSError as a client that left: it re-raises, nothing is answered, and the cause is never visible to the client.

What changed

  • serve/server.py, Vision.encode: a cache entry whose file is gone is dropped and the image is encoded again.
  • serve/server.py, _post: only ConnectionError / TimeoutError are treated as a client that left (as before). BadBody is re-raised to do_POST (400 / 413, as before). Any other exception raised before the answer began is a 500 that names it (internal server error (FileNotFoundError: ...)), with the traceback in the log, in the same shape as the existing 400 for a malformed body; an answer already begun is not replaced.
  • serve/test_vision_cache_missing.py: a hit with the file present is still a hit; a deleted file is encoded again. Fails without the change.
  • serve/test_internal_error_500.py: an unexpected OSError and another exception are a 500; ConnectionResetError, BadBody and an answer already begun are still re-raised; ValueError keeps its 400. Two tests fail without the change.

Extra Notes

  • Measured on Windows 11, RTX (CUDA), Qwen3.8-Flash-Next IQ3_S, installed from v0.1.43.1: with the .sve of one RGBA PNG (832x1248) deleted, a one-picture request dropped the connection in 0.02 s; the same bytes plus one trailing byte (another cache key) answered 200. With the change, the same request after deleting the file answers 200 and the .sve is written again; requests without pictures and with other pictures are unchanged, and a malformed body is still a 400.
  • On v0.1.43.1 the full serve suite passes with the change (733 tests, OK, 12 skipped). On this branch (current main) I could only run it in a checkout of serve/ without the native modules: 360 errors with and without the change, the same set, so none comes from this change.
  • I did not find what deleted the file. Here the cache dir was under %TEMP% (strata-vision-kp5r7rqe), which Windows Storage Sense and cleanup tools may empty while a server runs for days (a guess, not verified).

🤖 Generated with Claude Code


🔄 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/Niko1221/Strata/pull/3118 **Author:** [@kai-chop](https://github.com/kai-chop) **Created:** 10/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-vision-cache-500` --- ### 📝 Commits (1) - [`a66e941`](https://github.com/Niko1221/Strata/commit/a66e94129ce7d9083764784e3dd36e837529a055) fix(serve): a cached image whose .sve was deleted is encoded again; a 500 instead of a dropped connection ### 📊 Changes **3 files changed** (+142 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+16 -1) ➕ `serve/test_internal_error_500.py` (+71 -0) ➕ `serve/test_vision_cache_missing.py` (+55 -0) </details> ### 📄 Description ## Title Issue: none filed ## Summary A cached image whose `.sve` file has been deleted from the encoder's temp directory (`%TEMP%\strata-vision-*`; something cleaned it while the server ran) makes every request that carries that picture end with a dropped connection and no answer. Clients that resend the whole history (opencode, Claude Code) then fail every later request of the conversation; opencode reports only `ECONNRESET` and retries forever. Two causes, both still on `main`: 1. `Vision.encode` treats a key in `self.cache` as a hit without checking that its file still exists, so the engine is handed a missing file. 2. The resulting `FileNotFoundError` is an `OSError`, and `_post`'s `except OSError` treats every `OSError` as a client that left: it re-raises, nothing is answered, and the cause is never visible to the client. ## What changed - `serve/server.py`, `Vision.encode`: a cache entry whose file is gone is dropped and the image is encoded again. - `serve/server.py`, `_post`: only `ConnectionError` / `TimeoutError` are treated as a client that left (as before). `BadBody` is re-raised to `do_POST` (400 / 413, as before). Any other exception raised before the answer began is a `500` that names it (`internal server error (FileNotFoundError: ...)`), with the traceback in the log, in the same shape as the existing 400 for a malformed body; an answer already begun is not replaced. - `serve/test_vision_cache_missing.py`: a hit with the file present is still a hit; a deleted file is encoded again. Fails without the change. - `serve/test_internal_error_500.py`: an unexpected `OSError` and another exception are a 500; `ConnectionResetError`, `BadBody` and an answer already begun are still re-raised; `ValueError` keeps its 400. Two tests fail without the change. ## Extra Notes - Measured on Windows 11, RTX (CUDA), Qwen3.8-Flash-Next IQ3_S, installed from v0.1.43.1: with the `.sve` of one RGBA PNG (832x1248) deleted, a one-picture request dropped the connection in 0.02 s; the same bytes plus one trailing byte (another cache key) answered 200. With the change, the same request after deleting the file answers 200 and the `.sve` is written again; requests without pictures and with other pictures are unchanged, and a malformed body is still a 400. - On v0.1.43.1 the full `serve` suite passes with the change (733 tests, OK, 12 skipped). On this branch (current `main`) I could only run it in a checkout of `serve/` without the native modules: 360 errors with and without the change, the same set, so none comes from this change. - I did not find what deleted the file. Here the cache dir was under `%TEMP%` (`strata-vision-kp5r7rqe`), which Windows Storage Sense and cleanup tools may empty while a server runs for days (a guess, not verified). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:36:13 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4462
No description provided.