fix(lib/utils/proxy): with DBEUG_PROXIFIED_VALUES flag, run factory on next event loop if possible

Prevents an edge case where `proxify` with a cleanup causes subsequent `destructure` calls to error because the assigned value is no longer a proxified value.

See ./lib/externals/src/react-native-clipboard.ts for reference.
This commit is contained in:
PalmDevs 2025-07-14 10:02:17 +07:00
parent fbc2d0e796
commit 188e88ae47
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -132,10 +132,11 @@ export function proxify<T>(signal: () => T, options?: ProxifyOptions): T {
options?.cache ?? false,
])
if (__BUILD_FLAG_DEBUG_PROXIFIED_VALUES__) {
const v = unproxifyFromHint(hint)
if (v == null) DEBUG_warnNullishProxifiedValue()
}
if (__BUILD_FLAG_DEBUG_PROXIFIED_VALUES__)
(globalThis.setImmediate ?? ((x: () => void) => x()))(() => {
if (unproxifyFromHint(hint) == null)
DEBUG_warnNullishProxifiedValue()
})
return new Proxy(hint, _handler) as T
}