-
Notifications
You must be signed in to change notification settings - Fork 73
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
Command parsing hangs under unit test #330
Comments
Hi @john-u, thank you for raising this issue. If possible, can you share the project you are working on so I might give it a go? |
Thank you |
@john-u The master branch is using oclif v1 in cli package. Is there a branch I can fetch that has the changes to use core? |
Yes sorry about that, I forgot to push my branch. Here is a PR SmartThingsCommunity/smartthings-cli#238 |
@john-u I just ran the test you mentioned in the original post
Not what the state of this test might be. Running on Mac 11.6.2 |
@peternhale I noticed that as well while investigating this. If |
@john-u I tried the suggestions of adding the
I will discuss this with team mates, next week. |
- related to oclif/core#330
@john-u I believe I have reproduced this using a simpler project. Command in question does define, so not sure if the timeout I am seeing is the same that you are seeing.
|
If only one arg is specified as required, I would expect oclif to throw |
- related to oclif/core#330
- related to oclif/core#330
Maybe I experienced the same problem but with I have a gitlab pipeline with semantic release for an oclif app that's based on // parser/parse.ts around line 243
if (!arg.ignoreStdin && !stdinRead) {
// eslint-disable-next-line no-await-in-loop
let stdin = await readStdin() // <--- here the script hangs in a automated pipeline
if (stdin) {
stdin = stdin.trim()
args[i] = stdin
}
stdinRead = true
} so my current workaround is to provide the default value for optional arguments. |
@tft7000 Thank you for raising this issue. We will have a look. |
I've been looking into this today and it looks like the problem is in the parser inside that readStdin() call that @tft7000 identified. Where on line 26 of parse.ts it has:
the isTTY property isn't inherited by spawned child processes, and so is undefined rather than True. Changing it to
fixes the problem for me. Happy to raise a PR over the weekend if that would be helpful |
@MonochromeChameleon @john-u 1.3.1 has the fix from #363 - can you let me know if you're still seeing this issue? |
@mdonnalley : from my side I can say that with the fix from #363 in v1.3.1 |
Everything is working for me with version 1.3.1 as well - thanks for getting it merged and released so quickly! |
1.3.1 has resolved the hanging tests we were seeing as described above. Thank you! |
We have been using oclif v1 and unit test our CLI using jest. We follow the instruction in the oclif docs to use the static
Command.run
inside tests. When attempting to migrate the project from v1 to core, several of the tests had timeout failures which signified a hanging handler. I dug into the parsing differences between v1 and core and found that core has a new feature which falls back to reading fromstdin
if there are no arguments specified. This causes issues as our CLI has several commands which have only optional arguments. I am not aware of this being a known breaking change, as it isn't mentioned on the migration guide.Bug
I believe a summary of the issue is that calling Command.run() without args under test causes a hang at this line in the parser (waiting for input that will never arrive).
Current (core) behavior
Here is an example of one of our tests that is hanging with core.
It fails with the following.
The test just below it however passes on the same command since it includes args.
Environment
"@oclif/core": "^1.0.11 "
darwin-x64 node-v12.18.1
The text was updated successfully, but these errors were encountered: