Skip to content

A platform for community discussion. Free, open, simple.

FIX: Settle rate-limited workflow-call children through failure path (#42171)

Isaac Janzenf4b4a27bacd7
diff --git a/plugins/discourse-workflows/lib/discourse_workflows/workflow_call_continuation.rb b/plugins/discourse-workflows/lib/discourse_workflows/workflow_call_continuation.rb
index 863e765de11..ec1b79c28d9 100644
--- a/plugins/discourse-workflows/lib/discourse_workflows/workflow_call_continuation.rb
+++ b/plugins/discourse-workflows/lib/discourse_workflows/workflow_call_continuation.rb
@@ -122,7 +122,11 @@ module DiscourseWorkflows
)
execution = executor.run
- claimed.update!(child_execution_id: execution.id, status: :waiting) if execution.waiting?
+ if execution.waiting?
+ claimed.update!(child_execution_id: execution.id, status: :waiting)
+ elsif execution.error? || execution.rate_limited?
+ child_failed!(execution)
+ end
rescue => e
fail_run!(claimed || run, e.message)
end
diff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/workflow_call_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/workflow_call_spec.rb
index c4251ae6449..bbc5904544c 100644
--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/workflow_call_spec.rb
+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/workflow_call_spec.rb
@@ -503,6 +503,8 @@ RSpec.describe DiscourseWorkflows::Nodes::WorkflowCall::V1 do
execution.reload
call_step = execution.execution_data.find_step(node_id: "call-1")
run = DiscourseWorkflows::WorkflowCallRun.last
+ child_execution = run.child_execution
+ expect(child_execution).to be_error
expect(execution).to be_error
expect(execution.error).to include("finished with status 'error'")
expect(call_step["status"]).to eq("error")
@@ -510,6 +512,36 @@ RSpec.describe DiscourseWorkflows::Nodes::WorkflowCall::V1 do
expect(run).to be_error
end
+ context "when rate limiting is enabled" do
+ before { RateLimiter.enable }
+ after { RateLimiter.disable }
+
+ it "fails the parent when a child execution is rate limited before it starts" do
+ SiteSetting.discourse_workflows_max_executions_per_minute_per_workflow = 1
+ target = callable_workflow_with_set_fields([assignment("called", "yes")])
+ caller = caller_workflow_for(target)
+
+ warmup_execution = execute_workflow(target, trigger_node_id: "call-trigger")
+ expect(warmup_execution).to be_success
+
+ execution = execute_workflow(caller)
+ expect_parent_waiting_at_call(execution)
+ run_workflow_call_jobs
+
+ execution.reload
+ call_step = execution.execution_data.find_step(node_id: "call-1")
+ run = DiscourseWorkflows::WorkflowCallRun.last
+ child_execution = run.child_execution
+
+ expect(child_execution).to be_rate_limited
+ expect(execution).to be_error
+ expect(execution.error).to include("finished with status 'rate_limited'")
+ expect(call_step["status"]).to eq("error")
+ expect(call_step["error"]).to include("finished with status 'rate_limited'")
+ expect(run).to be_error
+ end
+ end
+
it "continues through regular output when an async child failure uses continueOnFail" do
target = failing_callable_workflow
caller =