Skip to content

Commit

Permalink
Fix fs.readSync potentially throwing EOF Error on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hieplpvip committed Jan 10, 2024
1 parent 16e61c5 commit f7407d0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/kattio.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ const Kattio = {
_ensure: function () {
if (this._bufPos === this._bufLen) {
this._bufPos = 0;
this._bufLen = fs.readSync(0, this._buf, 0, this._buf.length, null);
try {
this._bufLen = fs.readSync(0, this._buf, 0, this._buf.length, null);
} catch (error) {
// Ref: https://github.com/nodejs/node/issues/35997
if (error.code === 'EOF') {
this._bufLen = 0;
return;
}

throw error;
}
}
},

Expand Down

0 comments on commit f7407d0

Please sign in to comment.