Fix makeLazy not incrementing tries if factory errors
This commit is contained in:
parent
7f5aaada88
commit
4feaa40de7
|
@ -20,9 +20,10 @@ export function makeLazy<T>(factory: () => T, attempts = 5, { isIndirect = false
|
||||||
|
|
||||||
const getter = () => {
|
const getter = () => {
|
||||||
if (!cache && attempts > tries) {
|
if (!cache && attempts > tries) {
|
||||||
|
tries++;
|
||||||
cache = factory();
|
cache = factory();
|
||||||
if (!cache && attempts === ++tries && !isIndirect) {
|
if (!cache && attempts === tries && !isIndirect) {
|
||||||
console.error(`Lazy factory failed:\n\n${factory}`);
|
console.error(`makeLazy factory failed:\n\n${factory}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue