Avatar for the PrefectHQ user
PrefectHQ
prefect
BlogDocsChangelog

Fix worker crash when flow file is missing during hook execution

#18424
Comparing
fix-worker-crash-missing-flow-18420
(
8abd67d
) with
main
(
8f38dd5
)
CodSpeed Performance Gauge
0%
Improvements
0
Regressions
0
Untouched
2
New
0
Dropped
0
Ignored
6

Benchmarks

Passed

bench_import_prefect_flow
benches/bench_import.py::bench_import_prefect_flow
CodSpeed Performance Gauge
0%
1.3 s
1.3 s
bench_task_decorator
benches/bench_tasks.py::bench_task_decorator
CodSpeed Performance Gauge
0%
459.3 µs
461.5 µs

Ignored

bench_flow_call[options0]Ignored
benches/bench_flows.py::bench_flow_call[options0]
CodSpeed Performance Gauge
+4%
169.7 ms
162.5 ms
bench_flow_call[options1]Ignored
benches/bench_flows.py::bench_flow_call[options1]
CodSpeed Performance Gauge
0%
106 ms
106.1 ms
bench_flow_decoratorIgnored
benches/bench_flows.py::bench_flow_decorator
CodSpeed Performance Gauge
+7%
4.7 ms
4.4 ms
bench_import_prefectIgnored
benches/bench_import.py::bench_import_prefect
CodSpeed Performance Gauge
0%
2.7 ms
2.7 ms
bench_task_callIgnored
benches/bench_tasks.py::bench_task_call
CodSpeed Performance Gauge
+10%
177.8 ms
161.6 ms
bench_task_submitIgnored
benches/bench_tasks.py::bench_task_submit
CodSpeed Performance Gauge
-31%
3.9 ms
5.6 ms

Commits

Click on a commit to change the comparison range
Base
main
8f38dd5
0%
Fix process worker crash when flow file is missing during hook execution Closes #18420 This PR fixes a bug where process workers would crash if they couldn't load a flow file when trying to run on_crashed or on_cancellation hooks. This commonly occurs when a flow file is deleted after deployment. The fix ensures workers remain resilient by catching all exceptions (not just ObjectNotFound) when attempting to load flows for hook execution. The worker logs the error with full traceback but continues operating normally. Changes: - Modified `_run_on_crashed_hooks` to catch all exceptions with proper logging - Modified `_run_on_cancellation_hooks` to catch all exceptions with proper logging - Added integration test demonstrating worker resilience - Added parameterized unit tests for various exception types The integration test shows that workers can successfully run other flows after encountering a missing flow file, proving the fix maintains worker resilience. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
b5c2d95
22 hours ago
by zzstoatzz
0%
rename file
8abd67d
19 hours ago
by zzstoatzz
© 2025 CodSpeed Technology
Home Terms Privacy Docs