fix(rhai-workflow): prevent overflow-driven retry storm in scripted nodes#1336
Open
kshirajahere wants to merge 1 commit intomofa-org:mainfrom
Open
fix(rhai-workflow): prevent overflow-driven retry storm in scripted nodes#1336kshirajahere wants to merge 1 commit intomofa-org:mainfrom
kshirajahere wants to merge 1 commit intomofa-org:mainfrom
Conversation
In ScriptWorkflowNode::execute, retry delay used 100 * 2u64.pow(retry_count). For large retry_count values this overflows: - debug builds: panic (arithmetic overflow) - release builds: wraparound, often to 0ms, producing an unthrottled retry storm This is especially dangerous for scripted agentic patterns where max_retries may be configured dynamically: a single failing scripted node can hammer the runtime loop and downstream dependencies. Use checked arithmetic and clamp to a safe global cap (60s), then add a regression test covering retry_count values that previously overflowed (55, 63, 64, 65, 1000, u32::MAX).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a critical overflow in Rhai scripted workflow retry backoff used by agentic pipeline nodes.
ScriptWorkflowNode::execute previously used unchecked arithmetic:
For large retry counts, this overflows:
A �ms delay under repeated failure creates an unthrottled retry storm that can starve worker loops and overload downstream dependencies.
Related Issues
Closes #1329
Context
This directly impacts reliability of scripted agentic design patterns (conditional branches, transform chains, validation loops) built on ScriptWorkflowNode. Robust backoff behavior is foundational for iterative framework work under the GSoC “classic agentic design patterns” scope.
Changes
How you Tested
�ash cargo test -p mofa-extra script_node_retry_delay_large_count_is_capped -- --nocapture cargo test -p mofa-extra test_simple_workflow_execution -- --nocapture cargo test -p mofa-extra test_conditional_workflow -- --nocaptureAll passed.
Screenshots / Logs (if applicable)
Key output:
🧹 Checklist
Code Quality
Testing
Documentation
PR Hygiene
Deployment Notes (if applicable)
No migration required.
Additional Notes for Reviewers
This patch intentionally keeps existing retry semantics but removes overflow-driven undefined behavior by enforcing checked arithmetic + hard cap.