Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if binary exists before passing it to node-pty #44440

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

ravicious
Copy link
Member

Fixes #44385.

At some point between 0.11.0-beta29 to 1.1.0-beta5, node-pty stopped throwing errors on Linux and macOS if the command to execute doesn't exist (microsoft/node-pty#689). Instead, the PTY simply exits with error code 1.

This PR makes it so that we manually run the equivalent of Go's os/exec.LookPath before starting a terminal session. This way we can bubble up the error about a nonexistent command to the UI.

nonexistent-command

changelog: Fixed terminal sessions with a database CLI client in Teleport Connect hanging indefinitely if the client cannot be found

// start, it's reported through PtyProcess.prototype.onStartError. Similarly, the information
// about a successful start is also conveyed through an emitted event rather than the method
// returning with no error. Hence why we can ignore what this promise returns.
void this.ptyProcess.start(event.columns, event.rows).then(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the syntax recommended by no-floating-promises to explicitly mark a promise that we ignore. https://typescript-eslint.io/rules/no-floating-promises/#ignorevoid

Copy link
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -30,6 +30,7 @@
"split2": "4.2.0",
"strip-ansi": "^7.1.0",
"tar-fs": "^3.0.6",
"which": "^4.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's a small package, but maybe we could add @types/which?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, mostly to check out the flow of adding a new package with pnpm. ;)

@ravicious ravicious force-pushed the r7s/check-pty-exe branch from bc185d7 to ad7d66f Compare July 19, 2024 14:00
@ravicious ravicious enabled auto-merge July 19, 2024 14:01
@ravicious ravicious added this pull request to the merge queue Jul 19, 2024
Merged via the queue into master with commit 4aa48db Jul 19, 2024
38 checks passed
@ravicious ravicious deleted the r7s/check-pty-exe branch July 19, 2024 14:25
@public-teleport-github-review-bot

@ravicious See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed
branch/v16 Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Teleport Connect tab with CLI database client hangs if client is not found
3 participants