On CDP process error, let client decide how to close

Fixes issue where CDP closes the client, but client still registers a recv
operation.
This commit is contained in:
Karl Seguin
2025-02-17 12:05:25 +08:00
parent b60a91f53c
commit c4eeef2a86
2 changed files with 8 additions and 4 deletions

View File

@@ -114,15 +114,15 @@ pub const CDP = struct {
self.session = try self.browser.newSession(self);
}
pub fn processMessage(self: *CDP, msg: []const u8) void {
pub fn processMessage(self: *CDP, msg: []const u8) bool {
const arena = &self.message_arena;
defer _ = arena.reset(.{ .retain_with_limit = 1024 * 16 });
self.dispatch(arena.allocator(), self, msg) catch |err| {
log.err("failed to process message: {}\n{s}", .{ err, msg });
self.client.close(null);
return;
return false;
};
return true;
}
// Called from above, in processMessage which handles client messages