Skip to content

guard against uninitialized client race condition#329

Merged
jcreighton merged 1 commit intoapollographql:mainfrom
jeffhertzler:main
Dec 18, 2020
Merged

guard against uninitialized client race condition#329
jcreighton merged 1 commit intoapollographql:mainfrom
jeffhertzler:main

Conversation

@jeffhertzler
Copy link
Copy Markdown
Contributor

@jeffhertzler jeffhertzler commented Dec 17, 2020

with #321 there's a possibility of a race condition where the client had not been initialized yet but the logger function is getting called producing an error that looks like this:

Uncaught TypeError: Cannot read property 'cache' of null
    at ApolloClient.f [as devToolsHookCb] (backend.js:1)
    at QueryManager.onBroadcast (bundle.esm.js:2544)
    at QueryManager.broadcastQueries (bundle.esm.js:2001)
    at QueryManager.stopQuery (bundle.esm.js:1917)
    at ObservableQuery.tearDownQuery (bundle.esm.js:543)
    at eval (bundle.esm.js:473)
    at cleanupSubscription (Observable.js:107)
    at notifySubscription (Observable.js:168)
    at onNotify (Observable.js:195)
    at SubscriptionObserver.error (Observable.js:252)

I just added a guard to noop if the client has not been initialized yet. seems like there's probably a longer term fix that removes the race condition possibility in the first place, but that's beyond my understanding!

@apollo-cla
Copy link
Copy Markdown

@jeffhertzler: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@jcreighton jcreighton merged commit 150f133 into apollographql:main Dec 18, 2020
@jcreighton
Copy link
Copy Markdown
Contributor

Thanks @jeffhertzler!

@jcreighton jcreighton mentioned this pull request Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants