Repository navigation
Fix IP pools -> pool detail error for quick draw mcgraws - #2109
Closed
david-crespo wants to merge 2 commits into
Closed
david-crespo wants to merge 2 commits into
david-crespo wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Collaborator
Author
|
Superseded by #2110. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2107
At moderate psychological expense, @charliepark and I were able to determine that the following sequence of events is happening:
useQueryfetching utilization forip-pool-1(an async fetch with loading state in table cell)ip-pool-1to go to IP pool detail page before utilization fetch is completeip-pool-1useQueryto unmount andremoveObserverto get called (confirmed by adding logging insideremoveObserver)removeObservergoes fromuseSyncExternalStorecall toonUnsubscribetodestroyremoveObserversees that there are no remaining observers (becauseprefetchQueryis not an observer) on the utilization query and cancels it, which causes aCancelledErrorto be thrown inside ourprefetchQueryand ends itip-pool-1renders, and the hook that expects that utilization is prefetched fails its invariant, hence the error pageMitigations
Pretty early on I figured out that if I call
cancelQueriesmyself on the query in question before callingprefetchQuery, that kills all the previous page stuff before it has a chance to kill me. So that avoids the error. The problem with this is that it means we start the query over again, even if we've already gotten through 90% of the fetch by the time we start the loader. This is distasteful, but I could live with it.Once we really figured out what was going on, we were able to come up with a sneaker solution, which currently what we're doing in the diff: instead of canceling the query, manually add an observer right before we call
prefetchQueryso thatremoveObserverdoes not cancel the query. This works perfectly — if the request takes 2 seconds and we wait 1.5s to click the link, the next page loads very quick — but it is somewhat ridiculous.Solutions
One thing we could do is figure out why the unmount is happening earlier than we expect. If we can make that not happen, I think this problem goes away, because the first query doesn't get canceled until after the
prefetchQuerycall is complete.Another way would be to make all prefetches behave like observers for the duration of their fetch:
I doubt this is something RQ should take as a PR, it's too specific. Only way I can think of to swing it would be that
prefetchQuerytakes an option that makes it act as a subscriber.Next steps
I want to talk to the maintainer about this 😅