Skip to content

Commit

Permalink
match on message instead of code (which napi does not set) (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 authored Nov 12, 2024
1 parent 191dc4c commit 8c1a07c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function setCloseOnExec(fd: number, closeOnExec: boolean): void;
*_CLOEXEC` under the covers.
*/
export function getCloseOnExec(fd: number): boolean;
export class Pty {
export declare class Pty {
/** The pid of the forked process. */
pid: number;
constructor(opts: PtyOptions);
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-darwin-arm64",
"version": "3.4.0",
"version": "3.4.1",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-darwin-x64",
"version": "3.4.0",
"version": "3.4.1",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-linux-x64-gnu",
"version": "3.4.0",
"version": "3.4.1",
"os": [
"linux"
],
Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty",
"version": "3.4.0",
"version": "3.4.1",
"main": "dist/wrapper.js",
"types": "dist/wrapper.d.ts",
"author": "Szymon Kaliski <[email protected]>",
Expand All @@ -25,7 +25,7 @@
},
"license": "MIT",
"devDependencies": {
"@napi-rs/cli": "^2.18.2",
"@napi-rs/cli": "^2.18.4",
"@napi-rs/triples": "^1.2.0",
"@types/jest": "^29.5.11",
"@types/node": "^20.14.2",
Expand Down
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 8c1a07c

Please sign in to comment.