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

keypress() never returns and blocks ctrl+C when running under Bun #759

Closed
annervisser opened this issue Oct 18, 2024 · 0 comments · Fixed by #760
Closed

keypress() never returns and blocks ctrl+C when running under Bun #759

annervisser opened this issue Oct 18, 2024 · 0 comments · Fixed by #760

Comments

@annervisser
Copy link
Contributor

This seems to be caused by the node implementation of @cliffy/internal/runtime/read never resolving when ran with Bun.

I don't know if you intend to support Bun. If not, feel free to close this.

Reproduction:

// repro.mjs
import { keypress } from '@cliffy/keypress';

const { key } = await keypress();
console.log('You pressed: ' + key);
bun run repro.mjs

Expected behaviour

After pressing a key, You pressed: <key> is printed. The command exits
This works when running deno run repro.mjs or node run repro.mjs

Actual behaviour

The program never exit, cannot even be cancelled with ctrl+c or ctrl+d

annervisser added a commit to annervisser/deno-cliffy that referenced this issue Oct 19, 2024
Bun's node:process stdin implementation has multiple issues related to
raw mode, resuming, and ending it too early.

To work around this, this adds a custom branch for the read function
when running under Bun. It uses Bun's own stdin implementation to read
one chunk and then dispose the reader.

Fixes c4spar#759
@c4spar c4spar closed this as completed in db5ae30 Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant