Skip to content

Commit

Permalink
match on message instead of code (which napi does not set)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Nov 12, 2024
1 parent 191dc4c commit a7f2aa6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ export class Pty {
try {
ptyResize(this.#fd, size);
} catch (e: unknown) {
if (e instanceof Error && 'code' in e && e.code === 'EBADF') {
// napi-rs only throws strings so we must string match here
// https://docs.rs/napi/latest/napi/struct.Error.html#method.new
if (e instanceof Error && e.message.indexOf('os error 9') !== -1) {
// error 9 is EBADF
// EBADF means the file descriptor is invalid. This can happen if the PTY has already
// exited but we don't know about it yet. In that case, we just ignore the error.
return;
Expand Down

0 comments on commit a7f2aa6

Please sign in to comment.