TransientSolver's solve() method (src/simulation/TransientSolver.js, line 78) runs a while (this.time <= this.endTime) loop with no maximum iteration cap.
Problem
For small time steps or complex circuits, the solver can run millions of iterations without any guard.
Impact
- For a 10ms simulation at 100µs step, that's 100 iterations (fine)
- But if a user sets endTime=1s and timeStep=1µs, that's 1,000,000 matrix solves
- All results are accumulated in
this.results Map — memory grows linearly with iterations
- No way to cancel — the UI thread blocks until completion
Fix
const maxSteps = 100000; // Cap
let stepCount = 0;
while (this.time <= this.endTime) {
stepCount++;
if (stepCount > maxSteps) return { success: false, error: `Exceeded max ${maxSteps} simulation steps` }
...
}
Or use AsyncGenerator to yield after N steps, allowing UI cancellation.
TransientSolver's
solve()method (src/simulation/TransientSolver.js, line 78) runs awhile (this.time <= this.endTime)loop with no maximum iteration cap.Problem
For small time steps or complex circuits, the solver can run millions of iterations without any guard.
Impact
this.resultsMap — memory grows linearly with iterationsFix
Or use
AsyncGeneratorto yield after N steps, allowing UI cancellation.