Skip to content

Commit

Permalink
Runtime: flush output_channel if length over max length
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed May 2, 2022
1 parent da93131 commit 055aca0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runtime/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 055aca0

Please sign in to comment.