Open pt-hieu opened 1 year ago
Hi @pt-hieu 👋🏻 thanks for reporting this! Was there a version of Apollo Client you used where this was working?
Thanks for replying @bignimbus, I am not sure about this but we previously used 3.7.14
and then upgraded the package to 3.8.4
, one thing that I don't really understand is how our production does not have this bug
Issue Description
Hi Apollo Client team, I am running into an issue where
onCompleted
is not fired when running the execute function ofuseLazyQuery
withfetchPolicy
set tono-cache
ornetwork-only
The above snippet is from the reproduction repo, the expected behaviour would be to see an alert dialog appearing (because
onCompleted
gets called) but there's only 2 "Hello from promise" logs in console which means there's actual data returnedNote
onCompleted
had been previous called successfully in our production environment until I made some changes to cache'stypePolicies
which should not have affecteduseLazyQuery
, though in the reproduction I don't touchtypePolicies
onCompleted
is called again once I dropreact
'sStrictMode
handleErrorOrCompleted
(here) to debug and acknowledged that the condition is evaluated 3 times with the following values ofresult
sequentially:{ loading: true, networkStatus: 1 }
,{ loading: false, networkStatus: 7 }
and{ data: {...}, loading: false, networkStatus: 7 }
. I don't think that is the correct behaviourLink to Reproduction
https://github.com/pt-hieu/apollo-lazy-oncompleted-reproduce
Reproduction Steps
git clone https://github.com/pt-hieu/apollo-lazy-oncompleted-reproduce.git
pnpm i
to install dependenciespnpm dev
to bootstrap the dev serverhttp://localhost:4200
and open the console panel atInfo
channel to see the log