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

Sporadic "Command failed with exit code 1" but no test failure #11601

Closed
LinqLover opened this issue Jun 22, 2021 · 15 comments
Closed

Sporadic "Command failed with exit code 1" but no test failure #11601

LinqLover opened this issue Jun 22, 2021 · 15 comments

Comments

@LinqLover
Copy link

🐛 Bug Report

In the CI of my repository, I frequently see this error:

error Command failed with exit code 1.

However, the log before does not show any failure, just some passing tests and some console outputs from the code under test. Locally, I am unable to reproduce this issue.

My tests are defined as asynchronous functions, but I have taken care to use await appropriately so, in theory, this should not be an issue. Nevertheless, it seems as if jest ends before all tests have been completed.

To Reproduce

See link to repl below, unfortunately, the issue occurs sporadically only.

Expected behavior

Either the exit code should be zero, or there should be at least one failing test displayed, or there should be an error message if the test setup is wrong for whatever reason.

Link to repl or repo (highly encouraged)

Just check out my repository where I have collected a number of these flaky builds: LinqLover/downstream-repository-mining#65

envinfo

  • OS: Ubuntu 20.04.2 LTS
  • Node 14.17.0/x64
  • Yarn: v1.22.10
  • jest: ^26.6.3 => 26.6.3

Thanks in advance!

@LinqLover
Copy link
Author

In some cases, I also see some of my tests timing out. This is a problem of myself, of course, but could jest maybe fail to show up a proper timeout error if the test is running asynchronously?

@LinqLover
Copy link
Author

This is weird:

    thrown: "Exceeded timeout of 5000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

In the very first line of my (async) test, I do exactly this and set the timeout to 10000 ms. Apparently my test times out even before it starts ...

@LinqLover
Copy link
Author

This is the most obvious output I have gotten so far:

yarn run v1.22.10
$ cross-env NODE_OPTIONS=--experimental-vm-modules jest
(node:1806) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

(https://github.com/LinqLover/downstream-repository-mining/runs/2885248978#step:8)

@LinqLover
Copy link
Author

LinqLover commented Jun 22, 2021

Further investigation has revealed that the issue only appears when running tests from all test files together but not when I only run a single test file. I added some debugging statements at the end of each test and found out that sometimes jest indicates the success of one of these tests before the final console statement is printed!

I guess something with asynchronous test execution is broken. Everything after an await in my test apparently is executed after the jest has already registered the test as a success and then it hangs ...:

https://github.com/LinqLover/downstream-repository-mining/blob/0316d80141db5681eb53e59b306a0b13e851f7f8/test/npm-deps.test.ts#L56-L78

PS: I traced this further down and found out that in my case, the test execution will always be interrupted when the first asynchronous call to fs is awaited.

@LinqLover
Copy link
Author

Reproduction

$ git clone https://github.com/LinqLover/downstream-repository-mining.git
$ cd downstream-repository-mining
$ git checkout 0316d80141db5681eb53e59b306a0b13e851f7f8
$ yarn install
$ yarn test test/references.test.ts  # optionally run with option -i
  yarn run v1.22.10
  $ cross-env NODE_OPTIONS=--experimental-vm-modules jest test/references.test.ts
  (node:1712) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
  (Use `node --trace-warnings ...` to show where the warning was created)
  
   RUNS  test/references.test.ts
  error Command failed with exit code 1.

@syuilo
Copy link

syuilo commented Sep 20, 2022

I have the same issue.
Is there any workarounds?

@iliakan
Copy link

iliakan commented Jan 1, 2023

Any solution? Bump

@nvanganm
Copy link

nvanganm commented Feb 3, 2023

same issues , any work around?

@sandeep-asan
Copy link

I am facing the same issue after updating react-script from v4 to v5. any workaround or solution?

@damdafayton
Copy link

damdafayton commented Apr 5, 2023

same issue

Solved it: it was caused by a forgotten await in front of the async func which was logging after the test ended. Although all tests were passing because of this logging Jest was exiting with code:1

@TylerBarnes
Copy link

I had this issue because I had a few obsolete snapshots. Removing them caused it to exit properly

@quaos
Copy link

quaos commented Jul 14, 2023

Also run into this randomly with Jest v29.5.0 .
There was not "Logging after tests" message, but found this in between the tests:

(node:66) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 response listeners added to [ClientRequest]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Jul 13, 2024
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants