Skip to content
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

fresh_dio - Dio instance locked #46

Closed
kuhnroyal opened this issue Apr 16, 2021 · 4 comments
Closed

fresh_dio - Dio instance locked #46

kuhnroyal opened this issue Apr 16, 2021 · 4 comments

Comments

@kuhnroyal
Copy link

In the lastest 0.3.0 null-safety release, the Dio client is locked from making requests before refreshing the token.

Sadly this also includes the token refresh request itself.
Also see: https://github.com/felangel/fresh/pull/39/files#r614289083

There is an open PR #45 which removes the locking.
In general I think it is a good idea to lock the instance but it should occur after the refresh request is sent and unlocked after the response is received and the token is stored.

As a workaround a new Dio instance can be constructed.

@rtviwe
Copy link
Contributor

rtviwe commented Apr 17, 2021

You can just call dio.unlock() inside your refreshToken callback

@rtviwe
Copy link
Contributor

rtviwe commented Apr 17, 2021

Also before migrating to dio 4.0.0 there was not any locking (see https://github.com/felangel/fresh/blob/f2470c98cb94a315ebbfbca7e3bc82aea18b0dc5/packages/fresh_dio/lib/src/fresh.dart)

@rtviwe
Copy link
Contributor

rtviwe commented Apr 17, 2021

There is also another bug which I fixed in PR with adding refreshed token to headers. For some reason, it disappeared after this commit b457b26

@felangel
Copy link
Owner

This should be fixed as part of #45 and included in v0.3.1 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants