React-apollo: useQuery's onError callback is never fired

Created on 29 Jul 2019  ·  5Comments  ·  Source: apollographql/react-apollo

Intended outcome:
When a request made by useQuery fails, onError is fired

Actual outcome:
It never fires, whether it's a connection error, or a non-200 response

Version
@apollo/react-hooks 0.1.0-beta.10 (Can't get beta.11 to work at all due to #3270)

System:
OS: Windows 10
Binaries:
Node: 11.4.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.12.3 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.17763.1.0
npmPackages:
apollo-server-express: ^1.3.2 => 1.4.0

(This happens both on Windows and on a Linux Docker container though)

has-reproduction

Most helpful comment

For me it seems to be the opposite. onError is actually executed three or four times. onError gets executed every time data or loading is updated.

Using version 0.1.0-beta.11.

All 5 comments

For me it seems to be the opposite. onError is actually executed three or four times. onError gets executed every time data or loading is updated.

Using version 0.1.0-beta.11.

@kasvtv @alfiehub Can you try @apollo/[email protected] and let me know if that helps? I'm having difficulty re-creating either of these issues, so if that doesn't help would you mind putting together a small runnable repro?

@hwillson I've forked a sandbox I found in another issue and tried to recreate the multiple onError calls problem using 0.1.0-beta.12.
https://codesandbox.io/s/apolloreact-hooks-multiple-onerror-calls-p1ifr

It seems to still be occurring as you can see in the console.

@hwillson I've forked a sandbox I found in another issue and tried to recreate the multiple onError calls problem using 0.1.0-beta.12.
https://codesandbox.io/s/apolloreact-hooks-multiple-onerror-calls-p1ifr

It seems to still be occurring as you can see in the console.

For me on the sandbox on beta 11 it actually on fires once. But 12 It fires twice + the onCompleted gets fired.

I wonder whether it's because the of the cleanup function

Thanks for the reproduction @alfiehub - I'm looking into this now.

Was this page helpful?
0 / 5 - 0 ratings