josdejong / josdejong/mathjs

Attempt to lazily instantiate a class factory blows up stack

Open
#3,439 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
15.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When there is a recursive factory dependence imported into a math instance between a class and a function, when the class is resolved, a "maximum call stack exceeded" error occurs, as opposed to an intelligible error about the recursive dependency.

**To Reproduce**

Load the example code from #3429, and then
```
math.import({Dim: createDimType, add: createAddDim, subtract: createSubtractDim})
const d = new math.Dim(3, 0.1, {})
```

This dies with "RangeError: Maximum call stack size exceeded" rather than any error about the recursive dependencies.

I don't know if this is limited to class <=> function recursive dependencies, just the example that was hit is of that form so I didn't want to claim too broadly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.