Skip to content

Fix crash due to incorrect terminal output length calculation#21469

Merged
niik merged 1 commit intodevelopmentfrom
wide-load
Jan 19, 2026
Merged

Fix crash due to incorrect terminal output length calculation#21469
niik merged 1 commit intodevelopmentfrom
wide-load

Conversation

@niik
Copy link
Member

@niik niik commented Jan 16, 2026

Description

When a Buffer with multi-byte characters (like emoji) is pushed, chunk.length returns the byte count (8) instead of the string length (4), causing terminalOutputLength to be inflated. The while loop then over-prunes, removing all chunks and causing firstChunk to be undefined.

TypeError
Cannot read properties of undefined (reading 'length')
Socket.n (app/src/lib/git/core.ts:282:35)
Socket.emit (node:events:531:35)
addChunk (node:internal/streams/readable:561:12)
readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
Socket.Readable.push (node:internal/streams/readable:392:5)
Pipe.onStreamRead (node:internal/stream_base_commons:189:23)

This crash was introduced by #21319 and is on beta right now.

To reproduce create a file with like a megabyte of 😀 emoji and try to view it in the diff viewer.

node -e "process.stdout.end('😀'.repeat(1024*1024))" > emoji.txt

Screenshots

Release notes

Notes: [Fixed] Git output containing multibyte characters is handled correctly avoiding unexpected crashes

When a Buffer with multi-byte characters (like emoji) is pushed, chunk.length returns the byte count (8) instead of the string length (4), causing terminalOutputLength to be inflated. The while loop then over-prunes, removing all chunks and causing firstChunk to be undefined.
Copy link
Member

@sergiou87 sergiou87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: Nice catch!

@niik niik merged commit 7b25174 into development Jan 19, 2026
9 checks passed
@niik niik deleted the wide-load branch January 19, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants