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

Jest takes indefinitely long to finish #11520

Closed
icecream17 opened this issue Jun 3, 2021 · 11 comments
Closed

Jest takes indefinitely long to finish #11520

icecream17 opened this issue Jun 3, 2021 · 11 comments

Comments

@icecream17
Copy link

icecream17 commented Jun 3, 2021

This is quite a random event that happened. Or rather, the event is still happening. When the action finishesdefault github action timeout is 360 minutes, more information will be posted. This is just a pre-report.

🐛 Bug Report

The check before the event took 37 seconds: https://github.com/icecream17/solver/runs/2737435482

But this check lasted 360 minutes (at which point Github auto-cancelled the ci): https://github.com/icecream17/solver/runs/2738671791

To Reproduce

Steps to reproduce the behavior:

Note: I just made these steps up. However, all 3 jobs are taking super long, so this is probably reproducible

  1. Clone at this exact commit: icecream17/solver@703561b
  2. When the github actions automatically runs, the step running jest takes super long

Update: See 3rd comment

Expected behavior

There should be a timeout error... but nothing is happening here.

Maybe my code has somehow evaded the default timeout, or there's an infinite loop.

Link to repl or repo (highly encouraged)

Since this is a random event, my repo isn't minimized or anything

Here's the commit link again: icecream17/solver@703561b

envinfo

There's 3 different operating systems. Also the tests are still running. Todo
image


@icecream17 icecream17 changed the title The github action running jest is taking 40+ minutes Jest is taking 40+ minutes (during github actions) Jun 3, 2021
@icecream17 icecream17 changed the title Jest is taking 40+ minutes (during github actions) Jest is taking 60+ minutes (during github actions) Jun 3, 2021
@icecream17
Copy link
Author

icecream17 commented Jun 3, 2021

Update: It's happening again - this is where the output froze
image

https://github.com/icecream17/solver/runs/2740077119

Cancelling this one though

@icecream17 icecream17 changed the title Jest is taking 60+ minutes (during github actions) Jest takes infinitely long to finish Jun 3, 2021
@icecream17
Copy link
Author

icecream17 commented Jun 3, 2021

Update: Github Actions has now failed the ci after the 360 minutes.

I'm now just going to say that it takes forever.pun

Also, this isn't limited to github actions - running on a regular terminal also takes forever.

Here's some modified repro steps:

  1. clone my solver repo (see above)
  2. npm install
  3. npm test

I can now provide envinfo:

  System:
    OS: Windows 10 10.0.19042
    CPU: (4) x64 Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
  Binaries:
    Node: 16.2.0 - C:\Program Files\nodejs\node.EXE     
    npm: 7.15.1 - C:\Program Files\nodejs\npm.CMD

npm test runs craco test, which is just something that modifies react-scripts test. And create-react-app uses jest for testing.

@icecream17 icecream17 changed the title Jest takes infinitely long to finish Jest takes indefinitely long to finish Jun 3, 2021
@icecream17
Copy link
Author

icecream17 commented Jun 4, 2021

I've isolated which test is taking indefinitely long:

commit that skips test: icecream17/solver@d803e9d#diff-20c86208e27d2f9659751b9824586495f177d8b41fc5a6a9c7ec0f5842788f90

line @ file @ commit: https://github.com/icecream17/solver/blob/703561b446e94faef36d8f1f0985456375f22420/src/App.test.tsx#L26

Interestingly, the loop finishes, but the test doesn't. (This isn't shown in the logs, just discovered while I was debugging)

So maybe there's some weird shenanigans with promises or something. (will post more later)

@pumano
Copy link

pumano commented Jun 18, 2021

i got same long running tests but don't understand root cause

@akauppi
Copy link

akauppi commented Jul 7, 2021

Just my 2c.

I have seen cases where an unresolved Promise keeps the Jest process from returning to the OS level (and thus CI times out, like yours did).

If there is an unresolved Promise in some test, is Jest supposed to be able to ”kill it all” and continue? If so, it clearly doesn’t. That could be the title of the issue, but I’m frankly not sure what the intended behaviour is.

What I’m intending to do about this, is to make the Promise aware of timing out, and finish itself. I hope this will ease the problem on my side. Providing the link, in case someone wants to follow up there:

akauppi/firebase-jest-testing#31


Edit: It wasn't about promises, but the Firebase Admin SDK keeps Jest from returning to OS level, if any listeners are still active. #11464

@icecream17
Copy link
Author

icecream17 commented Jul 15, 2021

The test now fails instead of taking forever

Right now, here's what happens:

  1. Something is clicked
  2. The test finishes
  3. Inside an async event handler, setState is called on an element that doesn't exist anymore.
  4. console.error is displayed

(Testing on newer code, icecream17/solver@9292971 but with test.only in App.test.tsx line 27)

  console.info
    248

      at Object.<anonymous> (src/App.test.tsx:40:12)

 PASS  src/App.test.tsx (9.321 s)
  √ Click everything (6657 ms)
  ○ skipped getting the main element
  ○ skipped a header exists
  ○ skipped Strategy sections exist
  ○ skipped The alert system
  ○ skipped The prompt system
  ○ skipped Strategy control testing

  console.error
    Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
        at StrategyItem (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\AsideElems\StrategyItem.tsx:40:36)
        at ol
        at StrategyList (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\AsideElems\StrategyList.tsx:21:36)
        at fieldset
        at div
        at SolverPart (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\AsideElems\SolverPart.tsx:28:34)
        at section
        at Aside (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\Aside.tsx:25:29)  
        at div
        at App (C:\Users\Steven\Documents\code\js\sudoku\solver\src\App.tsx:39:7)

      124 |       // strategyItem UI - update lastStrategyItem
      125 |       if (this.latestStrategyItem !== null) {
    > 126 |          this.latestStrategyItem.setState({ isCurrentStrategy: false })
          |                                  ^
      127 |          await forComponentsToUpdate()
      128 |       }
      129 |

      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnAboutUpdateOnUnmountedFiberInDEV (node_modules/react-dom/cjs/react-dom.development.js:23914:9)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21840:5)  
      at Object.enqueueSetState (node_modules/react-dom/cjs/react-dom.development.js:12467:5) 
      at StrategyItem.setState (node_modules/react/cjs/react.development.js:365:16)
      at Solver.Step (src/Api/Solver.ts:126:34)

  console.warn
    undefined strategyItemElement @2

      129 |
      130 |       if (this.strategyItemElements[this.strategyIndex] === undefined) {
    > 131 |          console.warn(`undefined strategyItemElement @${this.strategyIndex}`)     
          |                  ^
      132 |          window._custom.alert(
      133 |             "The code somehow can't find the Strategy Item", AlertType.ERROR      
      134 |          )

      at Solver.Step (src/Api/Solver.ts:131:18)
      at Solver.Go (src/Api/Solver.ts:199:10)

  console.error
    Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
        at App (C:\Users\Steven\Documents\code\js\sudoku\solver\src\App.tsx:39:7)

       97 |
       98 |    alert(message: string, alertType = AlertType.INFO) {
    >  99 |       this.setState(state => {
          |            ^
      100 |          const notices = state.notices.slice()
      101 |          notices.push({
      102 |             type: NoticeType.ALERT,

      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnAboutUpdateOnUnmountedFiberInDEV (node_modules/react-dom/cjs/react-dom.development.js:23914:9)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21840:5)  
      at Object.enqueueSetState (node_modules/react-dom/cjs/react-dom.development.js:12467:5) 
      at App.setState (node_modules/react/cjs/react.development.js:365:16)
      at App.alert (src/App.tsx:99:12)

  console.error
    Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
        at Cell (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\MainElems\Cell.tsx:73:28)
        at tr
        at Row (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\MainElems\Row.tsx:27:27)
        at tbody
        at table
        at Sudoku (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\MainElems\Sudoku.tsx:22:7)
        at main
        at Main (C:\Users\Steven\Documents\code\js\sudoku\solver\src\Elems\Main.tsx:22:28)    
        at div
        at App (C:\Users\Steven\Documents\code\js\sudoku\solver\src\App.tsx:39:7)

      76 |       for (const row of this.sudoku.cells) {
      77 |          for (const cell of row) {
    > 78 |             cell.setState({ explaining: true })
         |                  ^
      79 |          }
      80 |       }
      81 |       await forComponentsToUpdate()

      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnAboutUpdateOnUnmountedFiberInDEV (node_modules/react-dom/cjs/react-dom.development.js:23914:9)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21840:5)  
      at Object.enqueueSetState (node_modules/react-dom/cjs/react-dom.development.js:12467:5) 
      at Cell.setState (node_modules/react/cjs/react.development.js:365:16)
      at Solver.setupCells (src/Api/Solver.ts:78:18)

  console.warn
    undefined strategyItemElement @3

      129 |
      130 |       if (this.strategyItemElements[this.strategyIndex] === undefined) {
    > 131 |          console.warn(`undefined strategyItemElement @${this.strategyIndex}`)     
          |                  ^
      132 |          window._custom.alert(
      133 |             "The code somehow can't find the Strategy Item", AlertType.ERROR      
      134 |          )

      at Solver.Step (src/Api/Solver.ts:131:18)
      at Solver.Go (src/Api/Solver.ts:199:10)

Test Suites: 1 passed, 1 total
Tests:       6 skipped, 1 passed, 7 total
Snapshots:   0 total
Time:        11.02 s, estimated 112 s
Ran all test suites related to changed files.

Watch Usage
 › Press a to run all tests.
 › Press f to run only failed tests.
 › Press q to quit watch mode.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press Enter to trigger a test run.

@github-actions
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 Feb 17, 2023
@skovhus
Copy link
Contributor

skovhus commented Mar 2, 2023

@icecream17 is this still a problem with the latest release of Jest?

@github-actions github-actions bot removed the Stale label Mar 2, 2023
@skovhus
Copy link
Contributor

skovhus commented Mar 3, 2023

So it isn’t a problem or did you move to vitest? ;)

@icecream17
Copy link
Author

it hasn't really happened again

@github-actions
Copy link

github-actions bot commented Apr 3, 2023

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 Apr 3, 2023
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

5 participants