fix(extract-comments): decode Buffer sources before merging - #731
Merged
alexander-akait merged 1 commit intoSep 9, 2026
Merged
Conversation
|
|
🦋 Changeset detectedLatest commit: 47a31e2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
tlaurie-cl
marked this pull request as draft
September 8, 2026 22:10
tlaurie-cl
force-pushed
the
fix/extract-comments-buffer-source
branch
3 times, most recently
from
September 8, 2026 22:17
4f7af04 to
723bc21
Compare
An existing comments file emitted by another plugin can be backed by a Buffer, which has no split method. Decode it as UTF-8 before merging.
tlaurie-cl
force-pushed
the
fix/extract-comments-buffer-source
branch
from
September 8, 2026 22:19
723bc21 to
47a31e2
Compare
tlaurie-cl
marked this pull request as ready for review
September 8, 2026 22:43
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #731 +/- ##
==========================================
- Coverage 95.27% 95.22% -0.06%
==========================================
Files 4 4
Lines 1354 1360 +6
Branches 503 501 -2
==========================================
+ Hits 1290 1295 +5
- Misses 56 57 +1
Partials 8 8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #730.
Merging extracted comments into a file another plugin emitted calls
.split("\n\n")on itssource(), which isstring | Buffer. If the source is a Buffer, it crashes the build withprevSource.source.split is not a function.The fix checks whether
source()actually returned a string or Buffer, and decodes it withtoString("utf8")when it's a Buffer. The/** @type {string} */assertion is removed.This crash first appears in 5.9.0, but the
/** @type {string} */assertion is older: it was added in terser-webpack-plugin #381, when the merge only ever saw files this plugin itself had written, which were always strings. #716 then started merging into comment files that other plugins had already emitted, causing Buffers to newly reach.split().webpack5.110.3 depends on this plugin, so a project can hit the crash without depending on it directly.What kind of change does this PR introduce?
A fix.
Did you add tests for your changes?
Yes, one new test:
should work with the existing licenses file, when it is a Buffer.The new test fails on
mainwith theTypeErrorfrom the issue and passes with this change.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
None needed.
Use of AI
Cursor's Auto Intelligence mode was used with supervision to debug the issue, trace the regression, build the reproduction and fix branches, and draft the bug and PR. All submission output and code has been reviewed and cleaned up by myself.