Skip to content

Commit ccf6393

Browse files
authored
Merge pull request #832 from microsoft/tyriar/partial_eagain
Ensure partial writes are handled on EAGAIN
2 parents ebf3c8f + fb24916 commit ccf6393

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/unixTerminal.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ export class UnixTerminal extends Terminal {
189189
// than using the `net.Socket`/`tty.WriteStream` wrappers which swallow the
190190
// errors and cause the thread to block indefinitely.
191191
fs.write(this._fd, data, (err, written) => {
192+
// Requeue any partial writes
193+
if (written < data.length) {
194+
this._writeQueue.unshift(data.slice(written));
195+
}
196+
192197
if (err) {
193198
const errno = (err as any).errno;
194199
switch (errno) {
@@ -216,11 +221,6 @@ export class UnixTerminal extends Terminal {
216221
}
217222
}
218223

219-
// Requeue any partial writes
220-
if (written < data.length) {
221-
this._writeQueue.unshift(data.slice(written));
222-
}
223-
224224
// Using `setImmediate` here appears to corrupt the data, this may be what
225225
// the interleaving/dropped data comment is about in Node.js' tty module:
226226
// https://github.com/nodejs/node/blob/4cac2b94bed4bf02810be054e8f63c0048c66564/lib/tty.js#L106C1-L111C34

0 commit comments

Comments
 (0)