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

stash_dio crash when reading from named hive cache #13

Closed
tjarvstrand opened this issue May 28, 2021 · 4 comments
Closed

stash_dio crash when reading from named hive cache #13

tjarvstrand opened this issue May 28, 2021 · 4 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@tjarvstrand
Copy link
Contributor

Describe the bug
When trying to read from a named cache, the stash_dio_interceptor crashes when using stash_hive.

As an aside, maybe stash_dio could use a default name (or require a name) for the cache rather than generating a new one each time. Presumably one uses persistent storage like Hive to be able to reuse it between runs no? :)

To Reproduce

  1. Make a request to any URL that responds with headers that allow caching while using stash_dio with a named stash_hive cache
  2. Restart
  3. Make a request to the same URL again.

Expected behavior
The cached response should be returned

Actual behavior
There is a crash:

E/flutter (13275): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'
E/flutter (13275): #0      CacheInterceptorBuilder._onRequest (package:stash_dio/src/dio/interceptor_builder.dart:134:67)
E/flutter (13275): <asynchronous suspension>

Version
dio: 4.0.0
stash: 3.0.0
stash_dio: 3.0.0
stash_hive: 3.0.0

Additional context
This seems related to #9 but I didn't hit this before because I wasn't using a named cache and as such, a new one was created on each run.

@github-actions github-actions bot added this to To do in stash May 28, 2021
@ivoleitao ivoleitao self-assigned this May 28, 2021
@ivoleitao
Copy link
Owner

Weird one let me debug

@ivoleitao
Copy link
Owner

Ok I know what's happening. I will work on a fix ASAP

@ivoleitao ivoleitao moved this from To do to In progress in stash May 28, 2021
@ivoleitao ivoleitao added bug Something isn't working documentation Improvements or additions to documentation and removed bug Something isn't working documentation Improvements or additions to documentation labels May 28, 2021
ivoleitao added a commit that referenced this issue May 28, 2021
@ivoleitao
Copy link
Owner

It's fixed and available on version 3.0.1

stash automation moved this from In progress to Done May 28, 2021
@tjarvstrand
Copy link
Contributor Author

Looks to be working. Thanks for the qucik fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
stash
Done
Development

No branches or pull requests

2 participants