-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
bug: hook functions can only be called from within a prompt #1426
Comments
That's quite weird. Did you reach out to Stackblitz? I would assume they're not just running node - even though it looks like it when running |
@SBoudrias, thanks for your quick reply. As stated on the StackBlitz docs, web containers should provide "a native Node.js environment", so maybe this is not an issue on their side. I opened stackblitz/webcontainer-core#1467 in addition to this issue. |
It could be an issue with their environment support of Node.js async_hooks. It's been a recurring issue this year where support was lacking on platforms like Bun. Specifically, async_hooks are tricky around timers. And so, core utilities to bind a callback to an async hooks context would be missing or broken in some platforms. Specifically, I think Unrelated to this issue, I'm releasing performance improvements to Inquirer's loaders right right now. This will delay the start of animation, which maybe will fix that very specific issue you're running into 🤷🏻 (until you start doing async validation.) |
Thank you a lot for that complete explication! 🙏 |
According to this issue stackblitz/webcontainer-core#1169 (comment), you're right about async hooks. |
@SBoudrias, Stackblitz issue has been closed in favor of already tracked stackblitz/webcontainer-core#1169. I suggested to leave this issue open so I can check out performance improvements and keep in touch 😉 |
@SBoudrias, I updated dependencies on the Stackblitz reproduction to check |
The new inquirer ( The older API |
Apparently `inquirer` requires `async_hooks` which isn't supported in webcontainers, therefore prompting the user fails. Instead we always fall back to the default option. See: SBoudrias/Inquirer.js#1426
Description
When using inside Stackblitz,
input
prompt will crash with the following error after user validate its choice for input:HookError: [Inquirer] Hook functions can only be called from within a prompt
Error does not show inside a "classical" environment. Error does not seems to show for all available prompts (tested
select
: no error).Reproduction
Go to this Stackblitz playground, run
node index.js
inside terminal and validate any answer for the input prompt.The text was updated successfully, but these errors were encountered: