Global error handling precedes local '.catch()', causing possible infinite loop

kissge
0
kissge
commented 6 months ago

Version

v5.6.0

Reproduction link

https://codesandbox.io/embed/axios-global-error-handling-vct01?fontsize=14

Steps to reproduce

None

What is expected ?

Local error handling precedes and no alert is shown

What is actually happening?

Global error handling precedes and alert is shown

Additional comments?

When both a global error handling (via nuxt's plugin) and a local error handling (via '.catch()') are set, I would expect the former one works as 'default' error handler i.e. works only when there's no other ones handling the error instance.
However, current axios-module is not working as that.

(note: Some time before, a kind-of-dirty "hack" was known to monkey patch this problem (e.g. https://www.qcode.in/api-error-handling-in-vue-with-axios/), but this currently doesn't work because axios' behavior changed a year ago.
https://github.com/axios/axios/commit/5bfd2ea9f63e59efaef3f1a659b55bbb9778fce2#diff-91dcec0516f33811ee5fa71297160b3bR39 )

I think this is a design bug.
This also leads to infinite loop and consequent browser crash when some API call is invoked in global error handler, because that call cannot utilize '.catch()' mechanism, which is obviously undesirable.

bug
0
Informations
Bug Report โ€ข Open
#c284 - Created 6 months ago