You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I noticed that sometimes output isn't fully flushed if theres more than 4kb of output and the program exits really quickly
I suspect that this is due to the kernel buffering output between the controller and user fd but not 100% sure. I tried to minimize this in our own implementation of node-pty by polling for both TIOCINQ and TIOCOUTQ to be 0 on both fds before calling the exit handler but we still see it (although much more rarely)
Curious if you have thoughts here or if I'm just holding it wrong
reproduction
import*asptyfrom"node-pty";import{describe,test,vi,expect}from"vitest";describe("nodepty reliability",{repeats: 100},()=>{test("doesnt miss large output from fast commands",async()=>{constpayload=`hello`.repeat(4096);letbuffer="";constonExit=vi.fn();constptyProcess=pty.spawn("/bin/echo",["-n",payload],{});ptyProcess.onExit(onExit);ptyProcess.onData((data)=>{buffer=buffer+data;});awaitvi.waitFor(()=>expect(onExit).toHaveBeenCalledTimes(1));expect(onExit).toHaveBeenCalledWith({exitCode: 0,signal: 0});expect(buffer.toString().length).toBe(payload.length);});});
surprisingly, this is fine on MacOS but fails on linux
~/workspace$ uname -a
Linux 33c149080877 6.2.16 #1-NixOS SMP PREEMPT_DYNAMIC Tue Jan 1 00:00:00 UTC 1980 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered:
Hey! I noticed that sometimes output isn't fully flushed if theres more than 4kb of output and the program exits really quickly
I suspect that this is due to the kernel buffering output between the controller and user fd but not 100% sure. I tried to minimize this in our own implementation of node-pty by polling for both TIOCINQ and TIOCOUTQ to be 0 on both fds before calling the exit handler but we still see it (although much more rarely)
Curious if you have thoughts here or if I'm just holding it wrong
reproduction
surprisingly, this is fine on MacOS but fails on linux
The text was updated successfully, but these errors were encountered: