-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
@live LiveState unsubscribe cleanup function never gets called #4830
Comments
Tried forcing root queries to expire ASAP with
It successfully causes But the LiveState unsubscribe is still never called.
|
If This means that no records, including those with resolver subscriptions, will exist in the store. Consequently, the loop that iterates over storeIDs and checks for |
BOOM! Solved it. If I comment out the // if (references.size === 0) {
// console.debug('(RELAY)', 'RelayModernStore._collect clearing all records - no references');
// this._recordSource.clear();
// } else {
...
// } |
PROBLEM: This code bypasses relay/packages/relay-runtime/store/RelayModernStore.js Lines 726 to 730 in 733cc27
seems like we need to call relay/packages/relay-runtime/store/RelayModernStore.js Lines 738 to 745 in 733cc27
|
quick and dirty workaround const source = new RecordSource()
const store = new RelayStore(source, {
// WARNING: DO NOT REMOVE THIS LINE
// This is a workaround that unbreaks garbage collection in the Relay store
// See https://github.com/facebook/relay/issues/4830 for more info
// Without this, root queries will never be disposed and LiveState values will never unsubscribe
queryCacheExpirationTime: 1,
})
const network = Network.create(fetchOrSubscribe, fetchOrSubscribe)
const env = new Environment({ store, network })
// WARNING: DO NOT REMOVE THIS LINE
// This is a workaround that unbreaks garbage collection in the Relay store
// See https://github.com/facebook/relay/issues/4830 for more info
// RelayModernStore has two branches for clearing the store, one of which is broken
// this line forces the store to use the working branch
// by forcing the store to retain an extra root query
// because the failing branch checks `if (references.size === 0)`
env.retain(createOperationDescriptor(getRequest(graphql`query theRelayEnvironment__DummyQuery($id: ID!) { node(id:$id) { id } }`), { id: ROOT_ID })) // prettier-ignore |
related docs: #4831 |
after unmounting
LiveSubUnsubTestDemo
, I'm still getting the subscription ticks foreverconsole.log("liveSubUnsubTest", "unsubscribe")
is never calledThe text was updated successfully, but these errors were encountered: