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:
parent
fbc2d0e796
commit
188e88ae47
1 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue