You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TextEncoder.encodeInto() underfills the destination for some non-ASCII text #65994
There are two problems I found with TextEncoder.encodeInto(), both of which can cause encoding to stall even when the next char can fit the destination.
Appending ☺ should not change whether preceding chars can be read into the buffer, but there it is.
The bugs were introduced by the encodeInto() performance change in Node.js v25.4.0. The examples above use length 33 strings to exercise that optimized path(kSmallStringThreshold = 32). Unfortunately the current encodeInto.any.js WPT tests fail to expose the problems because:
all input cases use 7 or fewer code units
even then, the cases don't use chars between U+0400 and U+07FF, and
their cases don't contain a narrow dst capacity to reveal the signed-byte problem.
Activity
util: fix TextEncoder.encodeInto underfilling
XadillaX commentedon Sep 12, 2026
Thanks for the detailed report and proposed changes
I opened #65997 based on the proposal here, with tests for these cases. It also uses the replacement-aware UTF-16 API which is available now
Please take a look when you have time
encoding: fix two encodeInto() bugs that reject input that fits
util: fix TextEncoder.encodeInto underfilling
src: fix two encodeInto() bugs that reject input that fits
koal44 commentedon Sep 12, 2026
thx, I can confirm the surrogate-pair underfill you found too. looks good to me.
util: fix TextEncoder.encodeInto underfilling
util: fix TextEncoder.encodeInto underfilling
src: fix two encodeInto() bugs that reject input that fits
util: fix TextEncoder.encodeInto underfilling
util: fix TextEncoder.encodeInto underfilling