Closed dylang closed 2 years ago
// @niksy
I don’t know if we should fix this here or in map-age-cleaner
.
@dylang Do you have reproducible test case so we can create test for it?
Hi @niksy - thanks for taking a look at this.
Here's a minimal reproducible case: https://stackblitz.com/edit/p-memoize-issues-39?file=index.js
I agree map-age-cleaner
should address this. It was reported there in April and not addressed: https://github.com/SamVerschueren/map-age-cleaner/issues/8
Maybe we could use Number.MAX_SAFE_INTEGER
instead of Number.POSITIVE_INFINITY
as a workaround? That's 285,427 years, which hopefully our promises have been resolved by then. 😅
BTW, it seems that removing maxAge
hides the issue.
Maybe we could use
Number.MAX_SAFE_INTEGER
instead ofNumber.POSITIVE_INFINITY
as a workaround? That's 285,427 years, which hopefully our promises have been resolved by then. 😅
Unfortunately, Number.MAX_SAFE_INTEGER
throws same warning, since that’s also not 32-bit signed integer. Maximum value is 2147483647
and that’s (2 ** 31) - 1
which is like 596 hours. This seems like a reasonable solution if we don’t want to wait for the fix in map-age-cleaner
. What do you think @sindresorhus ?
Sounds good to me 👍
Happy new year 🎉
@sindresorhus done! And happy new year to you all!
Version
This is from
p-memoize@4.0.3
and possibly caused by #37.Stack
Theory
maxAge
toNumber.POSITIVE_INFINITY
. https://github.com/sindresorhus/p-memoize/blob/version-4/index.js#L29pSettle
is resolved (https://github.com/sindresorhus/p-memoize/blob/version-4/index.js#L32)maxAge
will continue to beNumber.POSITIVE_INFINITY
.mapAgeCleaner
is run. https://github.com/sindresorhus/p-memoize/blob/version-4/index.js#L13mapAgeCleaner
does not check ifmaxAge
is a safe integer. It usessetTimeout(..., maxAge)
.maxAge
to an integer), thensetTimeout
throws the above stack becauseNumber.POSITIVE_INFINITY
is not a 32 bit number.