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
ExpiryPolicy.eternal duration causes overflow when compiled to Javascript #7
Comments
Looks like it might be related to #5, I'm currently using package version 1.0.4. |
Yes, I've fixed this on the null version only. This is just the first problem there's a lot more as I haven't really tested this on dartjs before. It will be very hard to retrofit this as I had to fix a number of concurrency problems on the tests as well in order to have this fixed. Also I'm already moving to monorepo so the repo structure is completely changed. The best about this is that I will finally have a full encompassing CI process that will support dart js tests as well |
If you can move to the new published version (2.0.0-nullsafety.4) it would be ideal. |
Will do, many thanks. |
Describe the bug
ExpiryPolicy.eternal sets a duration that overflows Javascript's number type. This is specific to compiling to web.
To Reproduce
Steps to reproduce the behavior:
Nothing special required. Create a cache with Lfu eviction policy, and add any item to it. It'll work fine when running on the Dart VM, but throw an error when running in a web browser.
Expected behavior
Consistent behaviour on every platform.
Version
Dart SDK version: 2.12.2 (stable) (Wed Mar 17 10:30:20 2021 +0100) on "linux_x64"
Additional context
The problem can be fixed by reducing the value of the eternal constant in api/expiry/expiry_policy.dart:
abstract class ExpiryPolicy {
/// The value used to represent a eternal duration
static const Duration eternal = Duration(days: 999999);
...
It's presumably due to the difference in numeric precision between the Dart VM and Javascript, although that's just a guess; I didn't spend much time tracking it down other than the bare minimum necessary to fix my problem.
The text was updated successfully, but these errors were encountered: