Skip to content

Commit

Permalink
Fix "Maximum call stack size exceeded" bug (#8636)
Browse files Browse the repository at this point in the history
* Fix potential call stack size issue

* Update defaultExtractor.js

* add test to verify "Maximum call stack size exceeded" is fixed

* update changelog

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
  • Loading branch information
adamwathan and RobinMalfait committed Jun 14, 2022
1 parent 47327f4 commit 22eaad1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608))
- Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615))
- Detect alpha value in CSS `theme()` function when using quotes ([#8625](https://github.com/tailwindlabs/tailwindcss/pull/8625))
- Fix "Maximum call stack size exceeded" bug ([#8636](https://github.com/tailwindlabs/tailwindcss/pull/8636))

## [3.1.2] - 2022-06-10

Expand Down
2 changes: 1 addition & 1 deletion src/lib/defaultExtractor.js
Expand Up @@ -12,7 +12,7 @@ export function defaultExtractor(context) {
let results = []

for (let pattern of patterns) {
results.push(...(content.match(pattern) ?? []))
results = [...results, ...(content.match(pattern) ?? [])]
}

return results.filter((v) => v !== undefined).map(clipAtBalancedParens)
Expand Down
6 changes: 6 additions & 0 deletions tests/default-extractor.test.js
Expand Up @@ -476,3 +476,9 @@ test('multi-word + arbitrary values + quotes', async () => {

expect(extractions).toContain(`grid-cols-['repeat(2)']`)
})

test('a lot of data', () => {
let extractions = defaultExtractor('underline '.repeat(2 ** 17))

expect(extractions).toContain(`underline`)
})

0 comments on commit 22eaad1

Please sign in to comment.