-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow control/back pressure #2077
Comments
Here is whats going on with a very fast producer like The numbers in front are the actual length of Theoretical calculation:
The reality looks a bit different:
Note that this is constantly growing, I did not wait for a process to run into OOM or getting killed by the kernel. With
Conclusion: Systems that dont offer XON/OFF as flow control mechanism are likely to produce OOM for remote xterm.js usage with fast producers (both on server and client side). |
Proposal: This basically resembles the old stream API of nodejs: pty.on('data', data => {
if (!terminal.write(data)) {
pty.pause();
}
});
terminal.on('drain', () => pty.resume()); With websockets in between it gets more complicated - we have first to find a way to send the PAUSE/RESUME events through to the backend with low performance impact. Additional note: |
Maybe we should split this issue into 2 separate ones as I think there are 2 distinct problems:
|
@Tyriar Yes its basically two issues in one report. The second thing needs more thinking about the right way to integrate it. To me it seems all use cases are affected, except one - electron with pty and xterm.js within one event loop. |
Moved the bug part to #2108 |
This will be mainly a documentation task now I think? |
Left to do:
|
documentation done in xtermjs/xtermjs.org#103 |
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
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.
The text was updated successfully, but these errors were encountered: