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

Question function is throwing the value you type in (node <= v15.7.0) #36

Closed
a7ul opened this issue May 8, 2021 · 2 comments · Fixed by #37
Closed

Question function is throwing the value you type in (node <= v15.7.0) #36

a7ul opened this issue May 8, 2021 · 2 comments · Fixed by #37

Comments

@a7ul
Copy link
Contributor

a7ul commented May 8, 2021

Example:

This example usage of question always throws with the value you type.

test.mjs

#!/usr/bin/env zx

const answer = await question("Type something here: ");
console.log({ answer });

Expected Behavior

The output should look like this:

❯ ./test.mjs
Type something here: hello
{ answer: 'hello' }

Actual Behavior

❯ ./test.mjs

Type something here: hello

internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^
hello
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Steps to Reproduce the Problem

  1. create the example test.mjs above
  2. npm install -g zx
  3. chmod a+x ./test.mjs
  4. ./test.mjs

Specifications

  • Version: zx@1.2.0
  • Platform: mac OS Big Sur (Intel)
  • Node: v14.15.5

Current workaround

#!/usr/bin/env zx

const answer = await question("Type something here: ").catch((e) => e);
console.log({ answer });
@a7ul a7ul changed the title Question function is throwing error for all cases Question function is throwing the value you type in May 8, 2021
@antonmedv
Copy link
Collaborator

Strange, but for me everything is okay:

❯ node zx.mjs t.mjs
Type something here: sdfsdfsdfads
{ answer: 'sdfsdfsdfads' }

@a7ul
Copy link
Contributor Author

a7ul commented May 8, 2021

Interesting. I tried with node v15.8.0 and it works as usual.
Only in node v14 this is breaking.

@a7ul a7ul changed the title Question function is throwing the value you type in Question function is throwing the value you type in (node v14) May 8, 2021
@a7ul a7ul changed the title Question function is throwing the value you type in (node v14) Question function is throwing the value you type in (node <= v15.7.0) May 8, 2021
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.

2 participants