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

Bun support #403

Closed
olafur-palsson opened this issue Sep 12, 2023 · 11 comments
Closed

Bun support #403

olafur-palsson opened this issue Sep 12, 2023 · 11 comments

Comments

@olafur-palsson
Copy link

Is your feature request related to a problem?

This is something odd I noticed. It looks like in general prompts works except when you run two question sequentially.

// index.js
const prompts = require('prompts')
// Works just fine
const response1 = await prompts({
  type: 'text',
  name: 'msg',
  message: 'Question'
})

// Not possible to use inputs anymore
const response2 = await prompts({
  type: 'text',
  name: 'msg',
  message: 'Question'
})

Describe the solution you'd like

It works when running with bun like when running with node.

Describe alternatives you've considered

Using node lol.

Additional context

None

@ericklarsen
Copy link

it happened on my side too.

@sonyarianto
Copy link

true true just run bun run example.js on this repo and on second question my WSL is hang :)

@sonyarianto
Copy link

refer to this oven-sh/bun#4664

@olafur-palsson
Copy link
Author

olafur-palsson commented Sep 13, 2023

I took a look around and a lot of interactive cli stuff is having issues.
oven-sh/bun#4787
oven-sh/bun#5267
oven-sh/bun#5240
oven-sh/bun#3255
oven-sh/bun#2333

But here's one that says it's fixed in the upcoming bun release which was 1.0 at the time (@clack/prompts on npm) but I've been running it on Bun 1.0 and still have the same bug.
bombshell-dev/clack#159

@sonyarianto
Copy link

sonyarianto commented Sep 14, 2023

@olafur-palsson Hi, for me Bun with @clack/prompts is no problem, but with terkelg/prompts has the issue CMIIW.

In @clack/prompts to test is easy, just clone that repo, and run bun --bun run examples/basic/index.ts it run smooth :)

@olafur-palsson
Copy link
Author

olafur-palsson commented Sep 14, 2023

@sonyarianto
They have issue with these. There's some weird behavior when closing the readline interface in Bun I think.

Try running this one:

import * as p from '@clack/prompts';

await p.text({
  message: 'Where should we create your project?',
  placeholder: './lol',
})

await p.text({
  message: 'Where should we create your project?',
  placeholder: './lol',
})

I didn't read @clack/prompts but I know that terkelg/prompts creates readline interfaces and closes them for each question. Maybe @clack/prompts keeps it open longer?

@sonyarianto
Copy link

Hmmm with Bun 1.0.2 above script also still not working properly.

@sonyarianto
Copy link

sonyarianto commented Sep 16, 2023

@olafur-palsson butttt if you modify the code like this, inside the async then it will work smoothly.

index.js

import * as p from '@clack/prompts';

async function main() {
  const response1 = await p.text({
    message: 'Where should we create your project?',
    placeholder: './lol',
  });

  const response2 = await p.text({
    message: 'Where should we create your project?',
    placeholder: './lol',
  });
}

await main();

bun --bun run index.js

@qhariN
Copy link

qhariN commented Dec 15, 2023

This issue has already been addressed in the latest release of Bun, v1.0.18. You can find more details about the fix in the release notes: Bun v1.0.18 Release Notes.

@michaelhays
Copy link

Confirmed that this is no longer an issue with Bun v1.0.18, so this issue can probably be closed.

@terkelg terkelg closed this as completed Dec 28, 2023
@davidgomes
Copy link

This can still happen on Bun, even after their v1.0.18 version.

Here's a repro/bug on Bun's issue tracker: oven-sh/bun#9855 (comment)

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

No branches or pull requests

7 participants