question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query not being cleaned up when on Strict Mode

See original GitHub issue

Intended outcome: When unmounting a component that uses useQuery, it should clean up even when wrapped by Strict Mode.

Actual outcome: Updating the cache on which an unmount component depends, generates a react warning about memory leak.

How to reproduce the issue: https://codesandbox.io/s/nifty-heyrovsky-5cf34 1- Click on “John Smith” and wait for the page to load 2- Click on “Back” 3- Click on “Like” button right by “John Smith” 4- Observe the warning in the console.

Checking on Apollo DevTools, there seems to be more active queries than it should have been after a few times reproducing the issue. image Compared to when Strict mode is not active: image Versions

@apollo/client: 3.3.15
graphql: 15.4.0
react: 17.0.2
react-dom: 17.0.2
react-router-dom: 5.2.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
hwillsoncommented, Aug 3, 2021

This should be fixed with @apollo/client >= 3.4 - thanks!

3reactions
Ralinocommented, Aug 18, 2021

While the warning is gone, I still have the issue that the queries are not cleaned up with @apollo/client 3.4.8 when strict mode is enabled, as shown in this demo: https://codesandbox.io/s/nostalgic-solomon-4stu5

Looking at the active queries with the dev tools, it seems like a query is spawned twice, one with “__typename” queried as well and one without. But only the query with “__typename” is cleaned up. Without strict mode, only a query with “__typename” is spawned (and cleaned up).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Having issues with no transact strict mode in mysql - SitePoint
Please am facing issues with NO STRICT TRANS in my database, this is found in the Sql mode settings. And if it is...
Read more >
Solved: error "The query parameter 'username' is not suppo...
We have a workflow that does the following: 1- query the user infos of a ... error "The query parameter 'username' is not...
Read more >
How to turn on/off MySQL strict mode in localhost (xampp)?
First, check whether the strict mode is enabled or not in mysql using: SHOW VARIABLES ...
Read more >
Using strict mode in React 18: A guide to its new behaviors
Strict mode is trying to be future-ready with React's suspense-based architecture, making it more resilient for introspecting UI issues. Let's ...
Read more >
MySQL 5.7 Reference Manual :: 5.1.10 Server SQL Modes
ERROR_FOR_DIVISION_BY_ZERO is not part of strict mode, but should be used in ... mysql> SET sql_mode = ''; Query OK, 0 rows affected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found