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

Testing Warnings in Election Manager due to React Query #2798

Closed
adghayes opened this issue Nov 19, 2022 · 3 comments · Fixed by #3793
Closed

Testing Warnings in Election Manager due to React Query #2798

adghayes opened this issue Nov 19, 2022 · 3 comments · Fixed by #3793

Comments

@adghayes
Copy link
Collaborator

Since we've started using ReactQuery in election-manager, we get all sorts of console warnings during tests because ReactQuery is trying to do state updates after unmounting. It looks like others have had this issue: TanStack/query#432. It would make the tests a lot more readable if we could get this sorted out.

@adghayes
Copy link
Collaborator Author

  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 a useEffect cleanup function.
        at BallotScreen (/home/drew/code/vxsuite/frontends/election-manager/src/screens/ballot_screen.tsx:80:19)

      at printWarning (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnAboutUpdateOnUnmountedFiberInDEV (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:23914:9)
      at scheduleUpdateOnFiber (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:21840:5)
      at dispatchAction (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:16139:5)
      at handleStoreChange (../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@17.0.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js:188:9)
      at ../../node_modules/.pnpm/@tanstack/react-query@4.2.3_react-dom@17.0.1+react@17.0.1/node_modules/@tanstack/query-core/build/esm/index.js:717:9

  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 a useEffect cleanup function.
        at AppRoot (/home/drew/code/vxsuite/frontends/election-manager/src/app_root.tsx:58:3)
        at Router (/home/drew/code/vxsuite/node_modules/.pnpm/react-router@5.2.0_react@17.0.1/node_modules/react-router/cjs/react-router.js:99:30)
        at BrowserRouter (/home/drew/code/vxsuite/node_modules/.pnpm/react-router-dom@5.2.0_react@17.0.1/node_modules/react-router-dom/cjs/react-router-dom.js:67:35)
        at App (/home/drew/code/vxsuite/frontends/election-manager/src/app.tsx:12:3)
        at QueryClientProvider (/home/drew/code/vxsuite/node_modules/.pnpm/@tanstack/react-query@4.2.3_react-dom@17.0.1+react@17.0.1/node_modules/@tanstack/react-query/src/QueryClientProvider.tsx:71:3)
        at RootElement (/home/drew/code/vxsuite/frontends/election-manager/test/render_in_app_context.tsx:93:5)

      at printWarning (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnAboutUpdateOnUnmountedFiberInDEV (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:23914:9)
      at scheduleUpdateOnFiber (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:21840:5)
      at dispatchAction (../../node_modules/.pnpm/react-dom@17.0.1_react@17.0.1/node_modules/react-dom/cjs/react-dom.development.js:16139:5)
      at handleStoreChange (../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@17.0.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js:188:9)
      at ../../node_modules/.pnpm/@tanstack/react-query@4.2.3_react-dom@17.0.1+react@17.0.1/node_modules/@tanstack/query-core/build/esm/index.js:717:9

 PASS  src/app.test.tsx (6.246 s)
  ✓ printing ballots and printed ballots report (724 ms)
  ✓ tabulating CVRs (2153 ms)
  ✓ tabulating CVRs with SEMS file (469 ms)
  ○ skipped create election works
  ○ skipped authentication works
  ○ skipped L&A (logic and accuracy) flow
  ○ skipped L&A features are available after test results are loaded
  ○ skipped tabulating CVRs with SEMS file and manual data
  ○ skipped changing election resets sems, cvr, and manual data files
  ○ skipped clearing all files after marking as official clears SEMS, CVR, and manual file
  ○ skipped Can not view or print ballots when using an election with gridlayouts (like NH)
  ○ skipped election manager UI has expected nav
  ○ skipped system administrator UI has expected nav
  ○ skipped system administrator UI has expected nav when no election
  ○ skipped system administrator Smartcards screen navigation
  ○ skipped election manager cannot auth onto unconfigured machine
  ○ skipped election manager cannot auth onto machine with different election hash
  ○ skipped system administrator Ballots tab and election manager Ballots tab have expected differences

Test Suites: 1 passed, 1 total
Tests:       15 skipped, 3 passed, 18 total
Snapshots:   2 passed, 2 total
Time:        6.255 s, estimated 7 s
Ran all test suites matching /app.test.tsx/i.

@adghayes
Copy link
Collaborator Author

For discussion, see: https://votingworks.slack.com/archives/C014MGC0WRE/p1669140935959929.

For PR fixing the warnings, see #2801.

@adghayes
Copy link
Collaborator Author

Will be fixed by #1660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant