Skip to content

fix(flow): prevent mutation of subflow runnerOptions and improve type safety#406

Merged
jafreck merged 1 commit intomainfrom
fix/subflow-runner-options-mutation
Mar 15, 2026
Merged

fix(flow): prevent mutation of subflow runnerOptions and improve type safety#406
jafreck merged 1 commit intomainfrom
fix/subflow-runner-options-mutation

Conversation

@jafreck
Copy link
Copy Markdown
Owner

@jafreck jafreck commented Mar 15, 2026

Summary

Follow-up to #405 — fixes a mutation bug and addresses three minor concerns from code review.

Changes

  1. Fix: runnerOptions mutation — Shallow-copy node.runnerOptions before writing the abort signal onto it. Previously, reusing a FlowDefinition across multiple FlowRunner.run() calls would leak the first run's AbortSignal into subsequent runs.

  2. Inherit continueOnError — The child runner now inherits the parent's continueOnError setting when the subflow's runnerOptions doesn't explicitly set it. Previously, child flows always defaulted to false regardless of the parent.

  3. Remove redundant type casts — The as FlowDefinition<Record<string, unknown>>, as Record<string, unknown>, and as FlowRunnerOptions<Record<string, unknown>> casts in the runner were unnecessary and hid poten3. Remove redundant type casts — The as Flopu3. **Remove redundant type casts** — The as FlowDefinition<Record<string, unknown>>re3. **Remove redundaput3. **Remove redundant type casts** — The as FlowDefinition<Record<string, unknown>>`ng

All All All Allow tests pass (118/118). No new tests needed — existing subflow tests already cover the affected code paths.

… safety

- Shallow-copy node.runnerOptions to avoid mutating the user-supplied
  object when propagating the parent abort signal. Reusing a flow
  definition across multiple runs could leak a stale signal.
- Inherit continueOnError from the parent runner when the subflow's
  runnerOptions does not explicitly set it.
- Remove unnecessary type casts (as FlowDefinition<Record<string, unknown>>,
  etc.) in the subflow executeNode handler.
- Add TInput generic to FlowSubflowNode so contextMap receives a typed
  input parameter instead of unknown, matching FlowStepNode conventions.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@af8fb14). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #406   +/-   ##
=======================================
  Coverage        ?   91.22%           
=======================================
  Files           ?      213           
  Lines           ?    22530           
  Branches        ?     3529           
=======================================
  Hits            ?    20553           
  Misses          ?     1929           
  Partials        ?       48           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jafreck jafreck merged commit 1f4bbc5 into main Mar 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant