From 22eaad17c33583b841d2086a9386dd5c1770061c Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Tue, 14 Jun 2022 08:17:40 -0400 Subject: [PATCH] Fix "Maximum call stack size exceeded" bug (#8636) * 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 --- CHANGELOG.md | 1 + src/lib/defaultExtractor.js | 2 +- tests/default-extractor.test.js | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f215d9c28..4c4d88d42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/lib/defaultExtractor.js b/src/lib/defaultExtractor.js index 9106bd593..4c28d007a 100644 --- a/src/lib/defaultExtractor.js +++ b/src/lib/defaultExtractor.js @@ -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) diff --git a/tests/default-extractor.test.js b/tests/default-extractor.test.js index d23dfd9cc..e0a39431a 100644 --- a/tests/default-extractor.test.js +++ b/tests/default-extractor.test.js @@ -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`) +})