<@ULVA73B9P> Task runs missing in prefect:3.4.19. ...
# ask-marvin
f
@Marvin Task runs missing in prefect:3.4.19. I checked the debug steps from here https://github.com/PrefectHQ/prefect/issues/15153#issuecomment-2364062064 but no luck. How can I fix it?
m
thought for 248.7 seconds
Thanks for the link — that thread is a good starting point. Since you’re on Prefect 3.4.19 and the debug steps there didn’t help, here’s a focused checklist to isolate and fix the common causes of “missing” task runs in 3.x, plus a minimal repro to test your environment. Quick UI checks - In the flow run page, Task Runs tab: set the time filter to “All time” and clear state/tag filters. The UI often defaults to a short time range. - Hard refresh the page. If you see a graph but the Task Runs table is empty, note that — it narrows things down. Code patterns that can hide task runs - Don’t call tasks with
.fn()
. That bypasses orchestration and no task runs get created. Use
task()
or
task.submit()
instead. - Avoid wrapping
@task
or
@flow
with your own decorators. In 3.x, extra wrappers can prevent Prefect from tracking calls (empty graph / missing logs / no task runs). As a test, remove any non-Prefect decorators and try again. If you need a decorator, apply Prefect’s decorator last and ensure you use
functools.wraps
, or better: put your logic inside the task/flow body. - Make sure tasks run in the flow’s process/thread, not inside threads/processes you start manually. Tasks scheduled outside the Prefect run context won’t be tracked. Minimal repro to test your server/client quickly - Start a fresh local server
Copy code
prefect server start
- Run this with your API URL set:
Copy code
export PREFECT_API_URL=<http://127.0.0.1:4200/api>

from prefect import flow, task

@task
def a():
    return "A"

@task
def b(x):
    return f"B({x})"

@flow
def f():
    x = a()          # or a.submit()
    y = b(x)
    return y

if __name__ == "__main__":
    print(f())
- You should see two task runs on the flow run page. If you don’t, the issue is environmental (server/DB/version), not your flow code. Verify they exist in the DB via the API - If the UI is empty, check directly via the client:
Copy code
import asyncio
from prefect.client.orchestration import get_client
from prefect.client.schemas.filters import TaskRunFilterFlowRunId

async def list_task_runs(flow_run_id: str):
    async with get_client() as client:
        trs = await client.read_task_runs(task_run_filter=TaskRunFilterFlowRunId(any_=[flow_run_id]))
        print(f"Found {len(trs)} task runs:", [tr.name for tr in trs])

# replace with a real flow_run_id from your UI/URL
asyncio.run(list_task_runs("YOUR-FLOW-RUN-ID"))
- If the client returns runs but UI shows none, it’s a UI/filtering/graph-render issue. If neither shows runs, they aren’t being created (code/wrappers/.fn()) or there’s a server write problem. Common environment causes and fixes - Version bug: There have been regressions in the past that impacted task run visibility. Try upgrading to the latest 3.x patch and retest: - Full changelog from 3.4.19 to next: 3.4.19→3.4.20 - Server errors: Check your server logs while opening the flow run page (look for exceptions around graph/task run endpoints). For example, failures on graph endpoints have caused empty displays in some versions. - DB issues: If you’re using SQLite, confirm the file is writable and not corrupted. If you’re comfortable testing in a clean environment, start a fresh server (new profile) and run the minimal flow above to rule out DB state problems. References - Original thread you cited: #15153 comment - Task run schemas (API filters): Docs: task runs If you can share a bit more, I can pinpoint this faster: - Are task runs missing only in the UI, or also via
PrefectClient.read_task_runs
? - Any custom decorators on your `@flow`/`@task` functions or use of
task.fn()
? - Local Server or Cloud? Which database (SQLite/Postgres)? - Any errors in your server or worker logs (especially when loading the flow run or graph tabs)?
Happy to review a small code snippet or logs — we can get you to a definitive fix quickly.