Skip to content

Commit f39a065

Browse files
author
Konrad Dysput
committed
sdk-core: Catch Array.isArray with proxies
1 parent 62ce490 commit f39a065

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎packages/sdk-core/src/common/limitObjectDepth.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ export function limitObjectDepth<T>(val: T, depth: number): Limited<T> {
3232

3333
const result: DeepPartial<T & object> = {};
3434
for (const key in val) {
35-
const value = val[key];
36-
if (Array.isArray(value)) {
37-
result[key] = value.map(limitChild) as never;
38-
} else {
39-
result[key] = limitChild(value) as never;
35+
try {
36+
const value = val[key];
37+
if (Array.isArray(value)) {
38+
result[key] = value.map(limitChild) as never;
39+
} else {
40+
result[key] = limitChild(value) as never;
41+
}
42+
} catch {
43+
// catch revoked proxies and other broken objects
44+
result[key] = REMOVED_PLACEHOLDER as never;
4045
}
4146
}
4247

0 commit comments

Comments
 (0)