Skip to content

Flow control/back pressure #2077

@jerch

Description

@jerch

The time-based input limiting contains a buffer, that gets drained only once all chunks were handled.
This way fast producers can easily exhaust memory and will crash the terminal / browser engine.

Relevant code:

xterm.js/src/Terminal.ts

Lines 1441 to 1447 in af81acc

if (this.writeBuffer.length > bufferOffset) {
// Allow renderer to catch up before processing the next batch
setTimeout(() => this._innerWrite(bufferOffset), 0);
} else {
this._writeInProgress = false;
this.writeBuffer = [];
}

Partial fix: Trim/slice already handled chunks from the buffer.

Even with this partial fix a long running producer that is faster than the terminal can handle incoming chunks will grow the buffer up to a possible crash. For a full fix we have to implement a reliable back pressure mechanism.

Metadata

Metadata

Assignees

Labels

type/documentationRegarding website, API documentation, README, etc.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions