Handle v8:Object::GetOwnPropertyNames returning null

This seems to only happen in error cases, most notably someone changes the
object to return an invalid ownKeys, as we see in WPT
/fetch/api/headers/headers-record.any.html
This commit is contained in:
Karl Seguin
2026-02-24 13:31:34 +08:00
parent 6b4db330d8
commit 2a332c0883
3 changed files with 25 additions and 9 deletions

View File

@@ -1209,13 +1209,20 @@ fn _debugValue(self: *const Local, js_val: js.Value, seen: *std.AutoHashMapUnman
gop.value_ptr.* = {};
}
const names_arr = js_obj.getOwnPropertyNames();
const len = names_arr.len();
if (depth > 20) {
return writer.writeAll("...deeply nested object...");
}
const own_len = js_obj.getOwnPropertyNames().len();
const names_arr = js_obj.getOwnPropertyNames() catch {
return writer.writeAll("...invalid object...");
};
const len = names_arr.len();
const own_len = blk: {
const own_names = js_obj.getOwnPropertyNames() catch break :blk 0;
break :blk own_names.len();
};
if (own_len == 0) {
const js_val_str = try js_val.toStringSlice();
if (js_val_str.len > 2000) {