apollographql / react-apollo

:recycle: React integration for Apollo Client
https://www.apollographql.com/docs/react/
MIT License
6.85k stars 790 forks source link

Errors that occur in refetchQueries cannot be caught #4043

Closed ysgk closed 4 years ago

ysgk commented 4 years ago

Intended outcome: One can handle errors that occur in refetchQueries.

Actual outcome: They cannot be caught.

How to reproduce the issue:

https://github.com/ysgk/react-apollo-error-template/tree/ysgk

Please run the app above and push the Logout button. You can confirm that errors cannot be caught in the catch block, nor in the onError callback.

const [logoutMutation, logoutResult] = useMutation(LOGOUT, { onError: () => { console.log('This line never gets called.') }})
const logout = () => logoutMutation({ awaitRefetchQueries: true, refetchQueries: [ { query: ALL_PEOPLE }]}).catch((e) => {
  // Errors that occur in refetchQueries cannot be caught.
  console.log('This line also never gets called.')
})
スクリーンショット 2020-07-17 0 47 09

Version

  System:
    OS: macOS 10.15.5
  Binaries:
    Node: 12.18.1 - ~/.nodebrew/current/bin/node
    Yarn: 1.22.4 - ~/.nodebrew/current/bin/yarn
    npm: 6.14.6 - ~/.nodebrew/current/bin/npm
  Browsers:
    Chrome: 83.0.4103.116
    Edge: 83.0.478.64
    Firefox: 77.0.1
    Safari: 13.1.1
  npmPackages:
    @apollo/client: ^3.0.0 => 3.0.0 
ysgk commented 4 years ago

Sorry, I found this was a duplication of https://github.com/apollographql/apollo-client/issues/3631