From d41d0f906f2efb5cd550b7ffe32c67739fc957ce Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Mon, 2 May 2022 17:48:49 +0200 Subject: [PATCH] Runtime: flush output_channel if length over max length --- runtime/io.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/io.js b/runtime/io.js index 6ce7926e16..ca90602e36 100644 --- a/runtime/io.js +++ b/runtime/io.js @@ -392,10 +392,17 @@ function caml_ml_output_bytes(chanid,buffer,offset,len) { caml_ml_flush (chanid); break case 1: // Buffered (the default) + chan.buffer+=jsstring; + if(chan.buffer.length > 65536) + caml_ml_flush (chanid); + break; case 2: // Buffered (only for stdout and stderr) var id = jsstring.lastIndexOf("\n"); - if(id < 0) + if(id < 0) { chan.buffer+=jsstring; + if(chan.buffer.length > 65536) + caml_ml_flush (chanid); + } else { chan.buffer+=jsstring.substr(0,id+1); caml_ml_flush (chanid);