Better error for primitives on proxyLazy + fix StartupTimings (#2339)

This commit is contained in:
Eric 2024-04-08 00:33:35 -04:00 committed by GitHub
parent e0becc1ba0
commit cba611c1cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -116,8 +116,11 @@ export function proxyLazy<T>(factory: () => T, attempts = 5, isChild = false): T
attempts,
true
);
return Reflect.get(target[kGET](), p, receiver);
const lazyTarget = target[kGET]();
if (typeof lazyTarget === "object" || typeof lazyTarget === "function") {
return Reflect.get(lazyTarget, p, receiver);
}
throw new Error("proxyLazy called on a primitive value");
}
}) as any;
}