jashkenas / jashkenas/underscore
Double chaining leads to a stack overflow
- Dominant language
- JavaScript
- Stars
- 27.3k
- Forks
- 5.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 1
Description
The following expression is useless, since you'd expect the second `chain` call to just return a new wrapper of the same value:
```js
_.chain([1]).chain()
```
but rather than behaving like a no-op, it results in a stack overflow. Credits to @reubenrybnik for pointing this out in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45201#issuecomment-637696652. This minor pitfall might have been introduced with #1691.
I'm hesitant to give this a "bug" label as it is rather non-urgent, but technically it's a bug. Documenting in an issue ticket for reference.
Contributor guide
Research direction
Reproduce the expression `_.chain([1]).chain()` and inspect the chain implementation and any related tests, using issue #1691 and pull request #2963 as context. Done means the second `chain` call no longer causes a stack overflow and behaves as the issue describes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100