-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token拦截器里的onError,使用 dio.interceptors.errorLock.lock() 无效 #877
Comments
I used my own completer to solve this .
|
拦截器锁的作用范围和dio实例是相关的,不同dio实例之间是相互隔离的,建议全局用同一个dio实例。如果业务场景需要创建多个dio实例,可以用你这种方法去同步多个dio实例。 |
你好,我当前是只有一个dio实例的,我用的是单例模式来包裹dio,我在onRequest里调用dio.lock(),确实其它一同发起的request都被lock住了,但在onError里调用dio.interceptors.errorLock.lock(),其它的error照样能进入onError()。 |
3.0.10已修复 |
|
I have been following this issue. I also encountered this problem in the previous Seeing that the author updated to my test:
|
dio 3.0.7
我创建了个Token拦截器,在onError里处理当token过期时,进行刷新的逻辑。
当我只有一个请求时,过程还是正常的,但当有多个请求同时进行时,我按照Example的例子使用了
dio.interceptors.errorLock.lock()
但我发现,即使使用了这个,其它请求同样也会因token失效的错误进入onError,导致
dio.interceptors.errorLock.lock()
多次被调用。似乎这个锁没有用。它们不是应该在那里阻塞吗?直到我unlock?
The text was updated successfully, but these errors were encountered: