PrefectHQ
prefect
BlogDocsChangelog

Fix nested `.delay()` serialization issue

#18849Merged
Comparing
fix-nested-task-delay-serialization
(
46d7cbd
) with
main
(
a845dc7
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s
bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
-1%
456.8 µs460.1 µs

Ignored

bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
2.7 ms2.7 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
106 ms106.1 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-11%
5.2 ms5.8 ms
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+3%
168.4 ms163.7 ms
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
+4%
168 ms161.2 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+5%
4.2 ms4 ms

Commits

Click on a commit to change the comparison range
Base
main
a845dc7
-0.38%
Fix nested task.delay() serialization issue When calling task.delay() from within another task that was itself called with .delay(), a TypeError would occur: 'MockValSer' object cannot be converted to 'SchemaSerializer'. The issue was in TaskRunContext.serialize() which used serialize_as_any=True globally, causing problems with Pydantic serialization. The fix follows the same pattern used for FlowRunContext - removing serialize_as_any from the main model_dump() and applying it only to result_store serialization. Added test to TestTaskWorkerNestedTasks to verify the fix.
46d7cbd
1 month ago
by zzstoatzz
© 2025 CodSpeed Technology
Home Terms Privacy Docs