pages.main_app: per-session temp directories leak and are never cleaned up #20

Open
opened 2026-10-06 13:47:53 +00:00 by ffrauenberger · 0 comments
Owner

Severity: low (temp files pile up on the server)

Where

  • app/pages/main_app.py:16-22
  • app/components/buttons.py:25-39
  • module.nix:250-265

Problem

  • main_app.py creates session_tmp_dir = tempfile.mkdtemp(...) once per session state.
  • to_home(), called by every Back/Home button and on many errors, runs st.session_state.clear(). That also removes session_tmp_dir, so the next run creates a new directory. The old one and its files (graph.png, graph.svg, graph.dot) are left behind.
  • The app never deletes these directories. The Nix cleanup job only deletes files (find … -type f -delete), so empty session_* directories accumulate indefinitely. Local and pip installs have no cleanup at all, so exported graphs of user data stay in /tmp.

Steps to reproduce

  1. Open the application, import a log, mine and export a graph
  2. Click Home, then repeat
  3. Inspect the temp directory

Expected behavior

One temp directory per session, removed when the session ends (or no temp files at all).

Actual behavior

A new session_* directory is created after every navigation home; old directories and their files remain.

Related: #34, #61.

Fix

Keep session_tmp_dir when clearing state, or remove the old directory first. Delete it when the session ends, or avoid temp files entirely (graph.pipe(format=...), see #41). Extend the Nix cleanup to empty directories (find … -mindepth 1 -empty -delete).


from issues/BUG-020-session-temp-directories-leak.md (code analysis of commit 6bcc646, 2026-10-03)

**Severity:** low (temp files pile up on the server) ## Where - `app/pages/main_app.py:16-22` - `app/components/buttons.py:25-39` - `module.nix:250-265` ## Problem - `main_app.py` creates `session_tmp_dir = tempfile.mkdtemp(...)` once per session state. - `to_home()`, called by every *Back*/*Home* button and on many errors, runs `st.session_state.clear()`. That also removes `session_tmp_dir`, so the next run creates a **new** directory. The old one and its files (`graph.png`, `graph.svg`, `graph.dot`) are left behind. - The app never deletes these directories. The Nix cleanup job only deletes files (`find … -type f -delete`), so empty `session_*` directories accumulate indefinitely. Local and pip installs have no cleanup at all, so exported graphs of user data stay in `/tmp`. ### Steps to reproduce 1. Open the application, import a log, mine and export a graph 2. Click *Home*, then repeat 3. Inspect the temp directory ### Expected behavior One temp directory per session, removed when the session ends (or no temp files at all). ### Actual behavior A new `session_*` directory is created after every navigation home; old directories and their files remain. Related: #34, #61. ## Fix Keep `session_tmp_dir` when clearing state, or remove the old directory first. Delete it when the session ends, or avoid temp files entirely (`graph.pipe(format=...)`, see #41). Extend the Nix cleanup to empty directories (`find … -mindepth 1 -empty -delete`). --- from `issues/BUG-020-session-temp-directories-leak.md` (code analysis of commit 6bcc646, 2026-10-03)
Sign in to join this conversation.
No milestone
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
ffrauenberger/ProcessIntel#20
No description provided.